Converting ADO Recordset to Cursor with CursorAdapter
By Sergey - Posted on January 1st, 2008
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
8 hours 28 min ago
1 week 20 hours ago
4 weeks 12 hours ago
5 weeks 2 hours ago
5 weeks 3 hours ago
7 weeks 4 days ago
8 weeks 1 day ago
8 weeks 1 day ago
8 weeks 4 days ago
8 weeks 4 days ago