BUG: Access ODBC Keyset Cursor Becomes Corrupt After a DeleteID: Q230131
|
After deleting a row and doing a MoveNext or MovePrevious, the current record is wrong.
Exhibited behavior indicates that the current record will either become another record from within the recordset or EOF depending on the size of the recordset.
A bug was introduced in MDAC 2.1 affecting the behavior of the Access ODBC Driver keyset cursors.
A supported fix that corrects this problem is now available from Microsoft, but it has not been fully regression tested and should be applied only to systems experiencing this specific problem.
Contacting Microsoft Product Support Services is not necessary unless you are having trouble installing or using this fix.
This hotfix has been posted to the following Internet location as JetODBC.exe:
http://www.microsoft.com/data
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
The specific MDAC 2.1 DLL causing the problem is odbcjt32.dll.
Version 4.0.3513.00 shipped with MDAC 2.1 that was included with
SQL Server 7.0.
Version 4.0.3711.08 of odbcjt32.dll shipped with MDAC 2.1 SP1.
MDAC 2.1 SP1 has shipped with Office 2000 and is downloadable at the MDAC Web site:
http://www.microsoft.com/data
Included in the hotfix download are both the Jet ODBC driver files and the Jet ISAM driver files. The Jet ODBC files are odbcjt32.dll and odbcji32.dll, the ISAM driver files are odexl32.dll, odfox32.dll, odpdx32.dll and odtext.dll.
CDBwindSet rs;
rs.Open();
rs.m_pDatabase->BeginTrans();
rs.MoveNext();
rs.Delete();
rs.MoveNext(); //You are now on the wrong record
rs.m_pDatabase->Rollback();
rs.Close();
The following Visual Basic code in conjunction with the Microsoft sample
Northwind database can be used to illustrate the behavior. The cursor type needs
to be adOpenDynamic. ADO will degrade to a keyset cursor because the Access ODBC
driver does not support dynamic cursors.
Dim cnNorthwind As ADODB.Connection
Dim rsOrderDetails As ADODB.Recordset
Private Sub Form_Load()
Dim strConn As String
Dim strSQL As String
strConn = "Provider=MSDASQL;Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\temp\NWind.MDB;"
strSQL = "SELECT * FROM [Order Details] ORDER BY OrderID, ProductID"
Set cnNorthwind = New ADODB.Connection
cnNorthwind.Open strConn
cnNorthwind.BeginTrans
Set rsOrderDetails = New ADODB.Recordset
rsOrderDetails.Open strSQL, cnNorthwind, adOpenDynamic, adLockOptimistic, adCmdText<BR/>
rsOrderDetails.MoveNext
MsgBox "Row 2 = " & rsOrderDetails!OrderID & " - " & rsOrderDetails!ProductID
rsOrderDetails.MoveFirst
rsOrderDetails.Delete
rsOrderDetails.MoveNext<BR/><BR/>
'Note you expect to be on Row 2 as before but you are not
MsgBox "Row 2 = " & rsOrderDetails!OrderID & " - " & rsOrderDetails!ProductID
rsOrderDetails.Close
cnNorthwind.RollbackTrans
cnNorthwind.Close
End Sub
Additional query words:
Keywords : kbADO210bug kbJET kbGrpVCDB
Version : WINDOWS:2.1,2.1 SP1
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: July 27, 1999