I have the following code that executes an XML template
query and returns the data into a stream.
Unfortunately it dont work completely... :(
I keep getting an error when i try to assign the output
stream to the command object.
The error i get when running it is:
"Item cannot be found in the collection corresponding to
the requested name or ordinal"
at the line oCmd.Properties("Output Stream") = strmOut
I have checked the documentation on MSDN and have received
articles from 15seconds that this property exists!?
I have been referencing Microsoft ActiveX Data objects 2.6
and 2.5....Both give me the same error?
Any ideas would be greatly appreciated!!
Cheers,
Hung
==========================================================
VB Code:
==========================================================
Dim oConn As New ADODB.Connection
Dim oCmd As New ADODB.Command
Dim oRs As New ADODB.Recordset
Dim sTemplate As String
Dim strmIn As New ADODB.Stream
Dim strmOut As New ADODB.Stream
sTemplate = "d:\xml\xml.txt"
oConn.ConnectionString
= "Provider=SQLOLEDB;server=scottishp3;Initial
Catalog=Northwind;User ID=sa;Password=password"
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"
With strmIn
.Open
.Charset = "UTF-8"
.LoadFromFile (sTemplate)
.Position = 0
End With
Set oCmd.CommandStream = strmIn
strmOut.Open
strmOut.Position = 0
strmOut.Charset = "UTF-8"
oCmd.Properties("Output Stream") = strmOut
oCmd.Execute , , adExecuteStream
MsgBox strmOut.ReadText
==========================================================
xml file: xml.txt
==========================================================
<?xml version="1.0" ?>
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<sql:query>select customerid TITLE, contactname ARTIST,
city from Customers CD FOR XML auto, elements</sql:query>
</ROOT>