Wiki Home

Cursor Adapter

Namespace: VB
A new base class introduced in VFP8

Provides access to four different data sources, yet provides the data from these sources as VFP cursors. The data sources include VFP native data (very similar in function to local views), ODBC data (similar to remote views and/or SQL pass through), OLE DB (by using ADO) and XML.

The Cursor Adapter is not a replacement for any of these technologies; instead, it is most useful at providing a consistent interface to these data sources in the UI of an application. For example, if you have some data stored in SQL Server and other data as XML files, you can access these two different data sources with two separately configured Cursor Adapter classes. The "presentation" of this data is done via an updatable VFP cursor, allowing you to bind to it in a UI, or process the data using standard VFP commands. -- Chuck Urwiler

Here is some super simple code. (allready exists: mssql, tempdb, table foo )
  • Get some data.
    lodo = CreateObject("CursorAdapter")
    lodo.DataSource=SQLStringConnect("DRIVER=SQL Server;Network=DBMSSOCN;SERVER=w2kas;database=(local);uid=sa;pwd=")
    lodo.SelectCmd="select * from foo"

    CursorAdapter VCX Builder for VFP 9
    Mark McCasland

    For those looking for some code, take a look at my article at
    -- Chuck Urwiler
    Is there a known issue getting output parameters back from stored procedures when using a very long command? For example, the following works perfectly:
    This.InsertCmd = "EXECUTE dbo.REFsp_InsertREFReturnReason @[email protected]_REFReturnReasonID, @ReturnReasonName=?ReturnReasonName"

    After using TABLEUPDATE(), the SP creates a record in SQL and passes back the PK as an output parameter - PK_REFReturnReasonID in my cursor is automatically populated with the newly inserted IDENTITY_SCOPE() value from SQL Server.

    However, another table has an InsertCmd that is approx 3500 characters long - the stored procedure executes without problems, the new record is inserted, but my field does not get populated from the output parameter. The parameter gets returned correctly when using Query Analyzer, but does not appear to be getting returned to VFP - I've tried returning it to both a variable and straight to the field but both times the value isn't being sent back. If I trim the command down to a few hundred characters then it works again. I've got memowidth set to 8192 and can't see why it refuses to work with a long InsertCmd! Could this be a limitation with the ODBC drivers? I'm using the latest MDAC 2.8 ones. -- Pete Naylor

    Is there a limit in external parameters?
    In the portal of "Comunidad de Visual Foxpro en Español" our friend Fernando Bozzo has a post about "Un EXE que no respeta los parámetros de entrada??" (An EXE that does not respect the input parameters?), where he exposes that he considered that the limite for executing an EXE compiled with VFP were 8192 characters, but he was executing something that uses very-less far from that with strange results.

    But he discovered in RUN command Help that there is a limit of 240 (two hundred and forty) chars.

    He investigated about a solution to his problem and found a solution based on API's Get Command LineOffsite link to

    I wait this helps to Pete Naylor.

    Hernán Cano Martínez, Colombia

    Jus discovered a Gotcha for native tables: list the .Tables without prefixing by the database! name otherwise, for an obscure reason, tableupdate won't work - Thierry Nivelet (Fox In Cloud)
    BTW, you can test updating data in Web mode using Cursor Adapter here:

    See also Cursor Adapter Or Not
    Category VFP 8 New Features
  • ( Topic last updated: 2016.08.02 09:33:35 AM )