Microsoft KB Archive/323920

= PRB: Run-Time Error When You Use SQLXML 2.0 with ADO to Execute an Updategram =

Article ID: 323920

Article Last Modified on 12/5/2003

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition
 * Microsoft ActiveX Data Objects 2.7
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Professional Edition

-



This article was previously published under Q323920



SYMPTOMS
If you use Microsoft SQLXML 2.0 with ActiveX Data Objects (ADO) to execute an updategram that specifies an XML Schema definition language (XSD) schema, and the SQLXML Version property of the connection object is set to a default value, you receive the following error message in Microsoft Visual Basic 6.0:

Run-time error '-2147217887 (80040e21)':

Specified attribute or element (' ') does not have a corresponding mapping in the schema, and no overflow field defined.



CAUSE
This behavior occurs because the SQLXML Version property is not set to &quot;SQLXML.2.0&quot;.

By default, the SQLXML Version property is set to the default value when you use the Microsoft OLE DB Provider for SQL Server (SQLOLEDB). The default value of this property uses the SQLXML feature that the Sqlxmlx.dll file provides. This .dll file is included with SQLXML 1.0 and Sqlxml2.dll is included with SQLXML 2.0.



WORKAROUND
To use the Sqlxml2.dll file with SQLOLEDB, you must set the SQLXML Version property to &quot;SQLXML.2.0&quot;. To do so, uncomment the following line from the Visual Basic code in step 2 of &quot;Steps to Reproduce the Behavior&quot; in the &quot;More Information&quot; section. conn.Properties(&quot;SQLXML Version&quot;) = &quot;SQLXML.2.0&quot;



Steps to Reproduce the Behavior
  Save the following XSD schema to your disk as EmpSchema.xml. Update the path that is specified in the code to where you saved the mapping schema. In this example, the schema is saved in C:\Schemas.           Use the following Visual Basic code to execute an updategram that has an associated mapping schema. The updategram updates the employee last name for employee &quot;1&quot; in the Employees table in the Northwind database. You must provide your user ID and password  in the connection string: Private Sub Form_Load Dim cmd As New ADODB.Command Dim conn As New ADODB.Connection Dim strmIn As New ADODB.Stream Dim strmOut As New ADODB.Stream

' Open a connection to the SQL Server. conn.Provider = &quot;SQLOLEDB&quot; conn.Open &quot;server=(local); database=Northwind; uid=UserName; pwd=UserPassword;&quot; ' conn.Properties(&quot;SQLXML Version&quot;) = &quot;SQLXML.2.0&quot; Set cmd.ActiveConnection = conn ' Open the command stream and write the template to it. strmIn.Open strmIn.WriteText &quot;<ROOT xmlns:updg='urn:schemas-microsoft-com:xml-updategram' >&quot; strmIn.WriteText &quot; <updg:header>&quot; strmIn.WriteText &quot;     <updg:param name='EmployeeID'/>&quot; strmIn.WriteText &quot;     <updg:param name='LastName' />&quot; strmIn.WriteText &quot; </updg:header>&quot; strmIn.WriteText &quot; <updg:sync mapping-schema='C:/Schemas/EmpSchema.xml' >&quot; strmIn.WriteText &quot;     <updg:before>&quot; strmIn.WriteText &quot;         <Emp  EmpID='1' />&quot; strmIn.WriteText &quot;     </updg:before>&quot; strmIn.WriteText &quot;     <updg:after>&quot; strmIn.WriteText &quot;         <Emp  LName='Fuller'/>&quot; strmIn.WriteText &quot;     </updg:after>&quot; strmIn.WriteText &quot; </updg:sync>&quot; strmIn.WriteText &quot;</ROOT>&quot; ' Set the command dialect to XML. cmd.Dialect = &quot;{5d531cb2-e6ed-11d2-b252-00c04f681b71}&quot; strmIn.Position = 0 Set cmd.CommandStream = strmIn ' Execute the command, open the return stream, and read the result. strmOut.Open strmOut.LineSeparator = adCRLF cmd.Properties(&quot;Output Stream&quot;).Value = strmOut cmd.Execute, , adExecuteStream strmOut.Position = 0 Debug.Print strmOut.ReadText strmOut.Close strmIn.Close conn.Close End Sub When you run this code from Visual Basic 6.0, you receive the error message that is described in the &quot;Summary&quot; section. </li></ol>

<div class="references_section">