BUG: First Row Is Not Saved if ADO Recordset Is Bound to Any Control and Persisted to XML (287083)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 2.5
  • ActiveX Data Objects (ADO) 2.6
  • ActiveX Data Objects (ADO) 2.7
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7

This article was previously published under Q287083

SYMPTOMS

If an ActiveX Data Object (ADO) recordset is bound to any bound control and is then persisted to XML, the first row is not saved.

RESOLUTION

There are two possible workarounds:
  • Use server-side cursors.
  • Save the recordset clone, which saves all of the records.

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. Open a new Standard EXE project in Visual Basic. Form1 is created by default.
  2. On the Project menu, click to select References. From the list of available references, select Microsoft ActiveX Data Objects 2.5 Library.
  3. Place a CommandButton and a TextBox control on Form1.
  4. Copy and paste the following code:
    Option Explicit
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    
    Private Sub Form_Load()
    Set cn = New ADODB.Connection
    cn.Open "Provider=SQLOLEDB.Connection;Data source=<SERVERNAME>;user id=sa;password=;Initial Catalog=Northwind;"
    cn.CursorLocation = adUseClient
    
    Set rs = New ADODB.Recordset
    rs.Open "Select Employeeid,Lastname,firstname,Birthdate from employees", cn, adOpenStatic, adLockReadOnly
    
    Set Text1.DataSource = rs
    Text1.DataField = "LastName"
    End Sub
    Private Sub Command1_Click()
    rs.Save "c:\temp\test.xml", adPersistXML
    
    End Sub
    					
  5. Run the program, click Command1, and then stop the project.
  6. Open test.xml, and note that the first record of the Employees table is not saved.

Modification Type:MajorLast Reviewed:5/8/2003
Keywords:kbbug kbDataBinding kbMSXMLnosweep kbpending KB287083