Microsoft KB Archive/290194

= BUG: DSO Recordset Pointer Is Corrupted If You Use the XML DSO LoadXml Method in Window_onLoad =

Article ID: 290194

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q290194



SYMPTOMS
If you use the LoadXml method of the Internet Explorer 5.5 XML Data Source object (DSO) to initialize its recordset structure and delete the initial record(s) in the Window_onLoad event procedure, the recordset pointer of the DSO is corrupted. The RecordCount property of the DSO's recordset appears as zero even after you add new records to it.

This problem is specific to the Internet Explorer 5.5 XML DSO and does not occur in Internet Explorer 5.



RESOLUTION
To work around this problem, use one of the following methods:
 * Specify the XML that is required to initialize the DSO's recordset structure within the DSO's  tag.
 * Persist the XML that is required to initialize the recordset structure in an external file, and reference it in the DSO's  tag with the SRC attribute.

For code that demonstrates these workarounds, 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 HTML file named DSOBug.html, and paste the following code:  

 Sub Window_onLoad xmlDSO.loadxml &quot;Beginning XML&quot; & _ &quot;<Publisher>Wrox</Publisher></Book></Books>&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

</SCRIPT>

<XML id=&quot;xmlDSO&quot;> </XML>

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

</BODY> </HTML>

</li> <li>Save DSOBug.html to your hard disk.</li> <li>In Internet Explorer 5.5, browse to DSOBug.html. When the page loads in the browser, the code in the Window_onLoad event procedure uses an XML string to run the LoadXml method of the XML DSO to initialize its recordset structure. In the call to the LoadXml method, the initial single record that is loaded into the DSO's recordset is deleted.</li> <li>On the HTML page, click Add Record to add a record to the DSO and display the RecordCount property of its recordset. Notice that the newly added record is displayed in the HTML table bound to the DSO, and that the RecordCount property of the DSO's recordset is displayed incorrectly as zero.</li></ol>

Workaround 1
<ol> <li>In Notepad, open DSOBug.html.</li> <li> Comment out the following statement in the Window_onLoad event procedure: 'xmlDSO.loadxml &quot;<Books><Book>Beginning XML</Title>&quot; & _ '              &quot;<Publisher>Wrox</Publisher></Book></Books>&quot; </li> <li> Modify the DSO's <XML> tag and its contents as follows to specify the XML that is used to initialize the DSO's recordset structure: <XML id=&quot;xmlDSO&quot;> <Books> <Book> Beginning XML</Title> <Publisher>Wrox</Publisher> </Book> </Books> </XML> </li> <li>In Internet Explorer, browse to DSOBug.html. 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 bound to the DSO, and that the RecordCount property of the DSO's recordset is displayed correctly.</li></ol>

Workaround 2
<ol> <li>In Notepad, open DSOBug.html.</li> <li> Comment out the following statement in the Window_onLoad event procedure: 'xmlDSO.loadxml &quot;<Books><Book>Beginning XML</Title>&quot; & _ '              &quot;<Publisher>Wrox</Publisher></Book></Books>&quot; </li> <li> In Notepad, create a new XML file named Data.xml, and paste the following code, which is used to initialize the DSO's recordset structure: <Books> <Book> Beginning XML</Title> <Publisher>Wrox</Publisher> </Book> </Books> </li> <li>Save Data.xml in the same folder as DSOBug.html.</li> <li> Modify the DSO's <XML> tag in DSOBug.html as follows to reference Data.xml using its SRC attribute: <XML id=&quot;xmlDSO&quot; SRC=&quot;Data.xml&quot;> </XML> </li> <li>In Internet Explorer, browse to DSOBug.html. 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 bound to the DSO, and that the RecordCount property of the DSO's recordset is displayed correctly.</li></ol>

Keywords: kbbug kbdhtml kbpending kbmsxmlnosweep KB290194

-

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

© Microsoft Corporation. All rights reserved.