Partager via


DelayedMemoFetch Method

Performs a delayed Memo field fetch for a target record in a cursor in a CursorAdapter object.

CursorAdapter.DelayedMemoFetch(cMemoName)

Parameters

  • cMemoName
    Specifies the name of the Memo field to be fetched in the current record of the cursor associated with the CursorAdapter object.

Remarks

Applies To: CursorAdapter Class

When the FetchMemo Property is set to False (.F.), the ability to perform a delayed Memo fetch is enabled. A delayed Memo fetch prevents the contents of Memo fields from being updated during CursorFill and CursorRefresh method calls. An attempt to fetch content for a Memo field is done when the application attempts to access that field's value. The following four CursorAdapter members enable you to use delayed Memo fetching.

  • DelayedMemoFetch Method

  • FetchMemoDataSourceType Property

  • FetchMemoDataSource Property

  • FetchMemoCmdList Property

The DelayedMemoFetch method performs a delayed memo fetch for the Memo field cMemoName in the current record. This method will return the contents of the specified Memo field. An error is raised if the data cannot be retrieved.

Note

For delayed Memo fetch to work with a CursorAdapter, the associated cursor should be opened in exclusive mode.

Note

The DelayedMemoFetch method should never be called other than to perform a delayed Memo fetch. Under no circumstances should this method change the current record.

To allow access to data in the target record, Visual FoxPro opens a read-only cursor with the target record as the current record. This read-only cursor is opened exclusively, and its alias is contained in the RefreshAlias property. If the RefreshAlias property is empty, then the DelayedMemoFetch method was not invoked by the Visual FoxPro data engine.

You can return the contents of a General field using DelayedMemoFetch. To do so, you need to convert the field contents to a Blob using the CAST( ) Function.

The following sample shows using DelayedMemoFetch to retrieve Memo and General field data from the Northwind Categories table via the Visual FoxPro OLE DB Provider.

CLOSE DATABASES all
CLEAR

LOCAL oCA as CursorAdapter
LOCAL oConn AS ADODB.Connection
LOCAL oRS AS ADODB.Recordset
LOCAL cConnStr,lcNorthwindFile 

lcNorthwindFile = HOME()+"Samples\Northwind\northwind.dbc"
cConnStr = [Provider=VFPOLEDB.1;Data Source=&lcNorthwindFile.;Password="";Collating Sequence=MACHINE]

oConn  = createobject('ADODB.Connection')
oConn.Open(cConnStr)
oRS = CREATEOBJECT("ADODB.Recordset")
oRS.ActiveConnection = oConn
oRS.CursorLocation = 3  && adUseClient
oRS.CursorType = 3&& adOpenStatic
oRS.LockType = 3&& adLockOptimistic

oCA=CREATEOBJECT("CADelayedFetch")
oCA.DataSource=oRS

IF !oCA.CursorFill()
AERROR(aerrs)
DISPLAY MEMORY LIKE aerrs
RETURN
ENDIF

GO TOP
BROWSE

DEFINE CLASS CADelayedFetch AS CursorAdapter
FetchMemo=.F.
DataSourceType="ADO"
SelectCmd="SELECT * from categories"
CursorSchema="categoryid i, categoryname c(15), description m, picture g"
UseCursorSchema=.T.

FUNCTION DelayedMemoFetch(cFieldName)
NODEFAULT
IF UPPER(cFieldName)==UPPER("picture")
RETURN CAST(DODEFAULT(cFieldName) as W)
ENDIF
RETURN [Modified value:] + DODEFAULT(cFieldName)
ENDFUNC
ENDDEFINE

See Also

Reference

RefreshAlias Property

FetchMemo Property

FetchMemoDataSource Property

FetchMemoDataSourceType Property

FetchMemoCmdList Property