Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


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.

↑ Back to the top


Properties

↑ Back to the top


Keywords: KB290050, kbpending, kbdhtml, kbbug, kbarchive, kbnosurvey

↑ Back to the top

Article Info
Article ID : 290050
Revision : 2
Created on : 10/23/2013
Published on : 10/23/2013
Exists online : False
Views : 313