When I try to access "MS Access" .mdb database using "native" Microsoft.Jet.OLEDB.4.0 provider I'm experiencing a problem with deleting of multiple records from previously retrieved recordset.
Here is an example:
// first, I open database in very usual way using ATL-based classes (mostly generated by OLEDB consumer-template wizard in VS)
CDataSource db;
CDBPropSet dbinit(DBPROPSET_DBINIT);
...................................
dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR("");
dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("Admin");
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, (LPOLESTR)szDBName);
dbinit.AddProperty(DBPROP_INIT_MODE, (long)16);
hr = db.Open(_T("Microsoft.Jet.OLEDB.4.0", &dbinit);
if( SUCCEEDED(hr) )
{
hr = m_session.Open( db );
return hr;
}
// then I use generated accessor class
(something like class CProducts : public CCommand<CAccessor<CProductsAccessor> >)
to open a rowset as a result of some SQL statement:
CProducts rs;
rs.Open();
// When I iterate through received recordset, processing data and deleting records using some criteria (or just all of them) like:
while( S_OK == rs.MoveNext() )
{
..................... // do something here
rs.Delete();
}
I receive "DB_S_ENDOFROWSET" just right after the second deletion, even though there is a lot more records in the recordset - without such deletion inside a loop I can successfully traverse entire recordset (all records) with no problems at all.
When I open DataSource using "MDASQL" as a provider instead of "Microsoft.Jet.OLEDB.4.0" everything works just fine (as it is supposed to work).
Initially blamed msjetoledb40.dll module, but installing the latest MSJETOLEDB40 Service Pack SP8 did not solve the problem.
Did I do something wrong, or somebody else had such problem and knew good workaround?
Best regards,
Andrey
Here is an example:
// first, I open database in very usual way using ATL-based classes (mostly generated by OLEDB consumer-template wizard in VS)
CDataSource db;
CDBPropSet dbinit(DBPROPSET_DBINIT);
...................................
dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR("");
dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("Admin");
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, (LPOLESTR)szDBName);
dbinit.AddProperty(DBPROP_INIT_MODE, (long)16);
hr = db.Open(_T("Microsoft.Jet.OLEDB.4.0", &dbinit);
if( SUCCEEDED(hr) )
{
hr = m_session.Open( db );
return hr;
}
// then I use generated accessor class
(something like class CProducts : public CCommand<CAccessor<CProductsAccessor> >)
to open a rowset as a result of some SQL statement:
CProducts rs;
rs.Open();
// When I iterate through received recordset, processing data and deleting records using some criteria (or just all of them) like:
while( S_OK == rs.MoveNext() )
{
..................... // do something here
rs.Delete();
}
I receive "DB_S_ENDOFROWSET" just right after the second deletion, even though there is a lot more records in the recordset - without such deletion inside a loop I can successfully traverse entire recordset (all records) with no problems at all.
When I open DataSource using "MDASQL" as a provider instead of "Microsoft.Jet.OLEDB.4.0" everything works just fine (as it is supposed to work).
Initially blamed msjetoledb40.dll module, but installing the latest MSJETOLEDB40 Service Pack SP8 did not solve the problem.
Did I do something wrong, or somebody else had such problem and knew good workaround?
Best regards,
Andrey