Executing XML queries agains SQL Server 2K

  • Thread starter Thread starter Marina
  • Start date Start date
M

Marina

Hi,

I am porting some VB6 code that was written in ADO. This code executes
queries against SQL2000 using its XML capabilities. It constructs and xml
doc, like the one below, which is then executed, and the results streamed
back.

I wrote some code to call the ExecuteXmlReader method of the SqlCommand
object, hoping that this was the equivalent. However, there are always
syntax problems with the XML tags.

By searching online, I read that the Provider needs to be set to SQLOLEDB
or SQLXMLOLEDB for this to work. SqlConnection however, does not support
that in the connect stream. And OleDB provider which does support Provider
in the connect stream, does not have an ExecuteXmlReader method.

I am not too familiar with using XML from ADO, so I'm not quite sure what
I'm doing, but what is the correct way to execute queries like this?


<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">

<query>Create view MyViews SELECT Col1 FROM Table1 </query>

<query>select * from MyViews as ROW for XML Auto,elements</query>

<query>drop view MyViews </query>

</ROOT>
 
I found the Microsoft.Data.SqlXml namespace, which looks like it's for this
exact purpose.
 
Back
Top