Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Microsoft.Jet.OLEDB.4.0" problem

Status
Not open for further replies.

agrafov

Programmer
Joined
Jan 6, 2004
Messages
6
Location
US
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 &quot;DB_S_ENDOFROWSET&quot; 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 &quot;MDASQL&quot; as a provider instead of &quot;Microsoft.Jet.OLEDB.4.0&quot; 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top