>When I run the query:
>Select * FROM Customers FOR XML AUTO
>in Query Analyzer (SQL Server 2000), I get the result in XML format.
>Is it anyway that I can retrieve the same result as a String in VB using ADO?
Hi Ari. I've done this before using a command object. Here's some sample pseudo-code that might help.... This sample uses an sproc, but by changing a few object properties you should be able to call a Select statement directly just as well.
Dim cmd As ADODB.Command
Dim objADOStream As ADODB.Stream
set cmd = createobject("ADODB.Command")
set objADOStream = createobject("ADODB.Stream")
'Create empty stream
objADOStream.Open
'Get the XML AUTO string
With cmd
.ActiveConnection = ConnectionString ' defined elsewhere
.CommandText = "up_MyStoredProc"
.CommandType = adCmdStoredProc
.Properties("Output Stream") = objADOStream
.Execute , , adExecuteStream
End With
Set cmd = Nothing
Set objADOStream = Nothing
msgbox objADOStream.ReadText(adReadAll)
The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. - Bertrand Russell