BUG: BatchCollisionCount is Incorrect After You Perform a BatchUpdate to SQL Server 7.0 Database (257658)



The information in this article applies to:

  • Microsoft SQL Server 7.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q257658

SYMPTOMS

After you perform a BatchUpdate from an rdoResultSet object to a Microsoft SQL Server 7.0 database, the BatchCollisionCount property is set incorrectly.

RESOLUTION

To work around this problem you can use Microsoft ActiveX Data Objects to connect to SQL Server 7.0.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Microsoft Visual Basic 6.0, create a new Standard EXE project. Form1 is added by default.
  2. Remove Form1, and then add a standard code module.
  3. From the Project menu, click References. In the References dialog box, select Microsoft Remote Data Object 2.0.
  4. 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
    					
  5. Run the application.
  6. 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.

Modification Type:MajorLast Reviewed:10/15/2002
Keywords:kbBug kbDatabase kbDSupport kbEEdition kbRDO KB257658