Output Stream(adExecuteStream) disappeared?

  • Thread starter Thread starter Porgányi Géza
  • Start date Start date
P

Porgányi Géza

Hi!

Before in ADO I used to get data from database with the technic below:
Stored procedure:

SELECT N'<XML><Data1>'
SELECT N'<Item>' + fField1 + '</Item>' FROM tbXXX WHERE ....
SELECT N'</Data1><Data2>'
SELECT N'<Item>' + fField2 + '</Item>' FROM tbYYY WHERE ....
SELECT N'</Data2>'
SELECT N'</XML>'

It results a well form structured XML. I could read it like this:
Dim adoConn as new ADODB.Connection
Dim adoCmd as new ADODB.Command
Dim adoStream as new ADODB.Stream
.....
adoStream.Open
adoCmd.Properties("Output Stream").value = adoStream
adocmd.Execute , , adExecuteStream
strTemp = adoStream.ReadText

In ADO.NET I can use ExecuteXMLReader to get xml string back, but it works
only with SELECT....FOR XML...., not with my generated one. It says it is
not a xml.
Is there a solution to use my old sps in .NET?
 
Porgányi Géza said:
Hi!

Before in ADO I used to get data from database with the technic below:
Stored procedure:

SELECT N'<XML><Data1>'
SELECT N'<Item>' + fField1 + '</Item>' FROM tbXXX WHERE ....
SELECT N'</Data1><Data2>'
SELECT N'<Item>' + fField2 + '</Item>' FROM tbYYY WHERE ....
SELECT N'</Data2>'
SELECT N'</XML>'

It results a well form structured XML. I could read it like this:
Dim adoConn as new ADODB.Connection
Dim adoCmd as new ADODB.Command
Dim adoStream as new ADODB.Stream
....

You'll need to do a normal ExecuteReader, and read the XML line by line.

dim dr as DataReader = cmd.ExecuteReader()
dim sb as new Text.StringBuilder
do while dr.Read()
sb.append(dr(0))
loop
dim d as new System.Xml.XmlDocument()
d.LoadXml(sb.ToString())

Or something like it
David
 
David Browne said:
You'll need to do a normal ExecuteReader, and read the XML line by line.

dim dr as DataReader = cmd.ExecuteReader()
dim sb as new Text.StringBuilder
do while dr.Read()
sb.append(dr(0))
loop
dim d as new System.Xml.XmlDocument()
d.LoadXml(sb.ToString())

Or something like it
David
It reads only the first SELECT. The iteration exits after first Read. (And
then of course xml is not well-form...)
Maybe I should write in the sp?
 
Porgányi Géza said:
"David Browne" <davidbaxterbrowne no potted (e-mail address removed)> az alábbiakat
írta a következo üzenetben news:%[email protected]...
It reads only the first SELECT. The iteration exits after first Read. (And
then of course xml is not well-form...)
Maybe I should write in the sp?
It works like this:
Do

While mSqlReader.Read

mStringBuilder.Append(mSqlReader(0).ToString)

End While

If mSqlReader.NextResult = False Then Exit Do

Loop


Thanks
 
Back
Top