BUG: SQL Server ODBC Driver 3.7 Bug with BatchUpdate and RDO (293867)



The information in this article applies to:

  • Microsoft SQL Server 7.0
  • Microsoft Data Access Components 2.5

This article was previously published under Q293867

SYMPTOMS

Remote Data Objects (RDO) may return the wrong status after a record is updated. This behavior occurs only with the SQL Server ODBC 3.7 driver. When multiple records are inserted, the first record correctly reports a status of 0, but the remaining records return a status of 2, even though the records were correctly inserted.

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. Create a data source name (DSN) called BatchTest for SQL Server.
  2. Use the following script to create a table in SQL Server:
    Create Table tblBatch (
    		ID integer Primary Key,
    		Code char (3) NULL,
    		ISBN char (3) NULL
    		)
    					
  3. Create a new Standard EXE project in Visual Basic. Form1 is created by default.
  4. Set a Project Reference to Microsoft Remote Data Object 2.0.
  5. Paste the following code into the code section of Form1:
    Option Explicit
    
    Private Sub Form_Load()
        On Local Error GoTo ErrorHandler
        
        Dim rdoConn As New rdoConnection
        Dim rdoRS As rdoResultset
        Dim sConnect, sSQL As String
        Dim iResult, iRowCount, iStatus, iCounter As Integer
        
        ' ODBC connection string
        sConnect = "DSN=BatchTest;"
           
        With rdoConn
            .Connect = sConnect
            .CursorDriver = rdUseClientBatch
            .EstablishConnection (rdDriverNoPrompt)
        End With
    
        ' The following code creates an Open recordset and then populates it.
        
        sSQL = "SELECT * From tblBatch"
    
        Set rdoRS = rdoConn.OpenResultset(sSQL, rdOpenStatic, rdConcurBatch, rdExecDirect)
        iRowCount = rdoRS.rdoColumns.Count
        
        With rdoRS
           
            .AddNew
            .rdoColumns(0) = 4
            .rdoColumns(1) = "ALA"
            .rdoColumns(2) = "A"
            .Update
            
            .AddNew
            .rdoColumns(0) = 5
            .rdoColumns(1) = "ALB"
            .rdoColumns(2) = "B"
            .Update
    
            .AddNew
            .rdoColumns(0) = 6
            .rdoColumns(1) = "ALC"
            .rdoColumns(2) = "C"
            .Update
            
            ' Check status BEFORE.
            Debug.Print "Added Local - Before BatchUpdate"
            iRowCount = .RowCount
            iCounter = 0
            .MoveFirst
            Do While Not .EOF
                iCounter = iCounter + 1
                Debug.Print "Row #" & iCounter & " of " & iRowCount & " is " & .Status
                .MoveNext
            Loop
            
            .BatchUpdate False, True
            
            ' Check status AFTER.
            Debug.Print "Added Local - After BatchUpdate"
            iRowCount = .RowCount
            iCounter = 0
            .MoveFirst
            Do While Not .EOF
                iCounter = iCounter + 1
                Debug.Print "Row #" & iCounter & " of " & iRowCount & " is " & .Status
                .MoveNext
            Loop
    
        End With
            
        MsgBox "Finished"
    
        rdoConn.Close
        
        Exit Sub
        
    ErrorHandler:
        Dim er As rdoError
        For Each er In rdoErrors
            Debug.Print "RDO Error -> " & er.Number & ": " & er.Description
        Next er
    End Sub
    					
  6. Run the code. The Immediate window reports the following status information:

    Added Local - Before BatchUpdate
    Row #1 of 3 is 1
    Row #2 of 3 is 1
    Row #3 of 3 is 1
    Added Local - After BatchUpdate
    Row #1 of 3 is 0
    Row #2 of 3 is 2
    Row #3 of 3 is 2
    						


Modification Type:MajorLast Reviewed:10/17/2003
Keywords:kbbug kbDatabase kbpending kbRDO KB293867