
CRecordset bulk read problem
Environment:
Windows XP Sp1
Visual C++ 6.0
MS SQL Server 2000
ODBC
Problem:
I have derived a recordset class from CRecordset,
and is using bulk row fetching. The data from the
database is fetched in batches of 25 rows (default
recordset size). If I terminate the operation when
x rows are handled, the remaining (25-x) rows will
turn up in the first batch when I restart the operation.
All is well so far, but the first batch will hold
x rows of invalid information, too. The next 25 rows
fetched will be valid again.
I have implemented the communication with the database in
a separate thread. When the operation is stopped, the
thread
is deleted along with the recordset and the database
connection
(CDatabase). The problem only arises when I recreate the
thread without terminating the application. I have traced
my
application to ensure that all recordsets and database
connections are destroyed when I delete the thread.
Example:
Operation started
Database connection established
Recordset opened
25 rows fetched
13 rows handled
Operation stopped
The recordset is closed
The database connection is closed
Operation restarted
The database connection is established
The recordset is opened
25 rows are fetched (verified by a call to
CRecordset::GetRowsFetched)
12 rows hold valid information
13 rows hold invalid information
25 rows are fetched
All 25 rows hold valid information
Kind regards
Kjell-?ke Boberg