After you perform a
BatchUpdate from an rdoResultSet object to a Microsoft SQL Server 7.0 database, the
BatchCollisionCount property is set incorrectly.
To work around this problem you can use Microsoft ActiveX Data Objects to connect to SQL Server 7.0.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Steps to Reproduce Behavior
- In Microsoft Visual Basic 6.0, create a new Standard EXE project. Form1 is added by default.
- Remove Form1, and then add a standard code module.
- From the Project menu, click References. In the References dialog box, select Microsoft Remote Data Object 2.0.
- Paste the code that follows into the code window for the module.
NOTE: Make sure that you modify the Connect property to connect to your SQL Server 7.0 server:
Public Sub Main()
Dim cn As New rdoConnection
Dim rs As rdoResultset
cn.CursorDriver = rdUseClientBatch
cn.Connect = "driver={sql server};server=ServerName;" & _
"database=pubs;uid=username;pwd=password;"
cn.EstablishConnection
Set rs = cn.OpenResultset("SELECT * FROM Authors", rdOpenKeyset, rdConcurBatch)
cn.Execute "UPDATE Authors SET au_lname = 'NewLastName'"
rs.MoveFirst
rs.Edit
rs!au_lname = "* RS UPDATE 1 *"
rs.Update
rs.MoveNext
rs.Edit
rs!au_lname = "* RS UPDATE 2 *"
rs.Update
rs.MoveNext
rs.Edit
rs!au_lname = "* RS UPDATE 3 *"
rs.Update
rs.BatchUpdate
If (rs.BatchCollisionCount = 3) Then
Debug.Print "BatchCollisionCount PASSED!! Count = " & _
rs.BatchCollisionCount
Else
Debug.Print "BatchCollisionCount FAILED!! Count = " & _
rs.BatchCollisionCount
End If
End Sub
- Run the application.
- From the View menu, click Immediate Window.
RESULTS: In the
Immediate (Debug) window, note that the
BatchCollisionCount is reported to be zero (0) or one (1). However, the
BatchCollisionCount should be 3.