We can forget about adAsyncFetch. This does not work with C. This and ADO event handling is possible only with VB etc and not with normal C.
Let us address your issue.
Normally opening a client side recordset should not take unduly long time as long as we judiciously select the size of the the data to be read.
Still if you want to mimic the ODBC fetch() record by record and then copy into your own memory, I suggest the following way:
Open serverside recordset with adOpenForwardOnly and adLockReadOnly. Keep reading the recordset as and when you need and copy to your memory ( array or whatever you were using with ODBC ). This is the fastest cursor possible.
Example:
I assume you have already opened the connection.
- Code: Select all Expand view
oRs := TOleAuto():New( "ADODB.RecordSet" )
WITH OBJECT oRs
:Source := <your sql statement>
:ActiveConnection := oCn
:CursorLocation := 2 // adUseServer
:LockType := 1 // adLockReadOnly
:CursorType := 0 // adOpenForwardOnly
//
:Open()
END
Whenever you want to fetch a record, execute code something like this:
if oRs:Eof()
// Already fetched all records. No more records
else
for n := 1 to oRs:Fields:Count()
aRow[ n ] := oRs:Fields( n - 1 ):Value
next n
AAdd( aData, aRow )
oRs:MoveNext()
endif
If you like, I give you here a shortcut code for the above:
- Code: Select all Expand view
if ! oRs:Eof()
AAdd( aData, oRs:GetRows( 1, 0 )[ 1 ] )
endif
With this you can do what you were doing using ODBC fetch() method.
My personal opinion is that you should stop thinking the ODBC way and start thinking the ADO way, same way as we should stop thinking the DBF way and start thinking the RDBMS way when we move to Relational Database systems.