D
DragonslayerApps
I am attempting to read XML data directly from a table in SQL Server
2000 using VB.Net 2003. When I run the code shown below, I get the
following error:
"SQLXML: invalid direct object (dbobject) query -><-"
I applied SqlXml 3.0 Service Pack 3 to both client and server. My
project references Microsoft.Data.SqlXml. Client is Windows XP Pro,
Server is Windows Server 2003 with SQL Server 2000. All service packs
and patches are current.
'----------------------------------------------------------------------------
Imports Microsoft.Data.SqlXml
Private Sub ReadXML()
Dim CS As String = "Provider=SQLOLEDB; Data Source=MyServer;
Initial Catalog=MyDB; User Id=MyUser; Password=MyPassword"
Try
Dim cmd As New SqlXmlCommand(CS)
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select parent_ID from tblData _
FOR XML AUTO, ELEMENTS"
Dim xr As XmlReader
xr = cmd.ExecuteXmlReader '<------Error happens here
xr.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
End Try
End Sub
Can anyone figure out what I'm missing? Specifying column names in the
SQL also has no effect. I tried adding a root tag to the command using
the code below before executing the reader but it had no effect.
cmd.RootTag = "xmlns:sql=""urn:schemas-microsoft-com:xml-sql"""
Thanks,
John
2000 using VB.Net 2003. When I run the code shown below, I get the
following error:
"SQLXML: invalid direct object (dbobject) query -><-"
I applied SqlXml 3.0 Service Pack 3 to both client and server. My
project references Microsoft.Data.SqlXml. Client is Windows XP Pro,
Server is Windows Server 2003 with SQL Server 2000. All service packs
and patches are current.
'----------------------------------------------------------------------------
Imports Microsoft.Data.SqlXml
Private Sub ReadXML()
Dim CS As String = "Provider=SQLOLEDB; Data Source=MyServer;
Initial Catalog=MyDB; User Id=MyUser; Password=MyPassword"
Try
Dim cmd As New SqlXmlCommand(CS)
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select parent_ID from tblData _
FOR XML AUTO, ELEMENTS"
Dim xr As XmlReader
xr = cmd.ExecuteXmlReader '<------Error happens here
xr.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
End Try
End Sub
Can anyone figure out what I'm missing? Specifying column names in the
SQL also has no effect. I tried adding a root tag to the command using
the code below before executing the reader but it had no effect.
cmd.RootTag = "xmlns:sql=""urn:schemas-microsoft-com:xml-sql"""
Thanks,
John