Microsoft KB Archive/290050

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

Article ID: 290050

Article Last Modified on 5/8/2003

-

APPLIES TO


 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer (Programming) 5.01 SP1
 * Microsoft Internet Explorer 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 &quot;More Information&quot; section.



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



Steps to Reproduce Behavior
  In Notepad, create a new file, and paste the following HTML code:  

 Sub Window_onLoad tabBooks.datasrc=&quot;#xmlDSO&quot; xmlDSO.Recordset.Delete End Sub

Sub AddBook xmlDSO.Recordset.AddNew xmlDSO.Recordset.Fields(&quot;Title&quot;) = &quot;XML Step By Step&quot; xmlDSO.Recordset.Fields(&quot;Publisher&quot;) = &quot;MS Press&quot; xmlDSO.Recordset.Update MsgBox &quot;Recordcount after AddNew : &quot; & xmlDSO.Recordset.recordcount End Sub



   Beginning XML <Publisher>Wrox</Publisher> </Book> </Books> </XML>

<BR> <INPUT type=button value=&quot;Add Record&quot; onClick=&quot;AddBook&quot;>

</BODY> </HTML> </li> <li>Save the file to your hard disk drive as DSOBug.html.</li> <li>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 &quot;tabBooks&quot; table and deletes the initial single record in the DSO's Recordset.</li> <li> 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
</li> <li>In Notepad, open DSOBug.html.</li> <li> Comment out the following statement in the Window_onLoad event procedure: 'tabBooks.datasrc=&quot;#xmlDSO&quot; </li> <li> Modify the </li> <li>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.</li></ol>

Keywords: kbbug kbdhtml kbpending KB290050

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.