BUG: XML Data Source Object Recordset Pointer Is Corrupted When You Delete Records in Window_onLoad() Event Procedure (290050)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 5.01
  • Microsoft Internet Explorer (Programming) 5.01 SP1
  • Microsoft Internet Explorer (Programming) 5.5

This article was previously published under Q290050

SYMPTOMS

When you bind HTML elements to the Internet Explorer XML Data Source Object (DSO) and delete its initial records in the Window_onLoad event procedure, the DSO's Recordset pointer is corrupted. The recordcount property of the DSO's Recordset remains zero even after new records are added to it.

RESOLUTION

This problem occurs only when you use scripting code in the Window_onLoad event procedure to bind the HTML elements to the XML DSO at run time. To work around this problem, set the DATASRC and DATAFLD Dynamic HTML (DHTML) attributes in their HTML tags to bind HTML elements to the XML DSO. For a step-by-step example, see the "More Information" section.

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 Notepad, create a new file, and paste the following HTML code:
    <HTML>
    <BODY>
    
    <SCRIPT Language="VBScript">
    Sub Window_onLoad()
       tabBooks.datasrc="#xmlDSO"   
       xmlDSO.Recordset.Delete      
    End Sub
    
    Sub AddBook()
      xmlDSO.Recordset.AddNew
      xmlDSO.Recordset.Fields("Title") = "XML Step By Step"
      xmlDSO.Recordset.Fields("Publisher") = "MS Press"
      xmlDSO.Recordset.Update
      MsgBox "Recordcount after AddNew : " & xmlDSO.Recordset.recordcount 
    End Sub
    
    </SCRIPT>
    
    <XML id="xmlDSO">
    <Books>
      <Book>
          <Title>Beginning XML</Title>
          <Publisher>Wrox</Publisher>
      </Book>    
    </Books>
    </XML>
    
    <TABLE id="tabBooks" border=1>
      <TR>
       <TD><span datafld="Title"></span></TD>
       <TD><span datafld="Publisher"></span></TD>
     </TR>
    </TABLE>
    
    <BR>
    <INPUT type=button value="Add Record" onClick="AddBook">
    
    </BODY>
    </HTML>
    					
  2. Save the file to your hard disk drive as DSOBug.html.
  3. Open DSOBug.html in Internet Explorer. When the page loads in the browser, the code in the Window_onLoad event procedure binds the XML DSO that is included in the page to the HTML "tabBooks" table and deletes the initial single record in the DSO's Recordset.
  4. Click Add Record on the HTML page to add a record to the DSO and display the recordcount property of its Recordset. Note that the newly added record is displayed in the HTML table and that the recordcount of the DSO's Recordset is displayed incorrectly as zero.

    Workaround

  5. In Notepad, open DSOBug.html.
  6. Comment out the following statement in the Window_onLoad() event procedure:
    'tabBooks.datasrc="#xmlDSO"
    					
  7. Modify the <TABLE> HTML element to implement the data binding by including the DATASRC attribute and setting it to the name of the XML DSO in the following code:
    <TABLE id="tabBooks" DATASRC="#xmlDSO" border=1>
      <TR>
       <TD><span datafld="Title"></span></TD>
       <TD><span datafld="Publisher"></span></TD>
     </TR>
    </TABLE>
    					
  8. In Internet Explorer, open DSOBug.html, and click Add Record to add a new record to the DSO's Recordset. Notice that the newly added record is displayed in the HTML table and that the recordcount of the DSO's Recordset is correctly displayed as 1.

Modification Type:MajorLast Reviewed:5/8/2003
Keywords:kbBug kbDHTML kbpending KB290050