Converting ADO Recordset to Cursor with CursorAdapter
CursorAdapter can easily convert ADO recordset into a VFP cursor. It does not support conversion in opposite direction.
| This is sample code. Add error handling and adjust to your requirements as necessary. |
CLOSE DATABASES ALL *----- Part 1 -----* * Create a recordset * Sql Server name/address lcSqlServer = "SQLTEST1" * SQL 2000 sample DB lcDb = "Pubs" lcSql = "SELECT * FROM Sales" * Open ADO connection oCon = CREATEOBJECT("ADODB.Connection") oCon.Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;" + ; "Initial Catalog=" + lcDb + ";Data Source=" + lcSqlServer) * Create recordset oRS = oCon.Execute(lcSql) *----- Part 2 -----* * Convert the ADO recordset to VFP cusor using CursorAdapter oCA = CREATEOBJECT("CursorAdapter") * Assign a cursor name oCA.Alias = "crsRS" oCA.DataSourceType = "ADO" * Fill the cursor from the recordset oCA.CursorFill(,,,oRS) * Detach cursor so it still be open after CursorAdapter is destroyed oCA.CursorDetach() * Destroy CursorAdapter oCA = NULL BROWSE LAST NOWAIT
Recent comments
1 week 5 days ago
1 week 5 days ago
2 weeks 2 hours ago
2 weeks 1 day ago
2 weeks 2 days ago
2 weeks 5 days ago
3 weeks 5 days ago
3 weeks 6 days ago
4 weeks 14 hours ago
4 weeks 4 days ago