Using FOR XML to retrieve data into VB

Using FOR XML to retrieve data into VB

Post by Robert Stricklan » Wed, 03 Jul 2002 20:56:58



What is the best way to retrieve XML from a select statement using FOR XML
into a variable in VB? When I run my query in Query Analyzer the XML looks
correct. But when I run my VB code to call the same proc (using the command
object only) the XML string looks different and incorrect. Does the stream
object some how fit in? What are the basic steps in getting XML from a
select or proc with a select from SQL2000 to VB?
 
 
 

Using FOR XML to retrieve data into VB

Post by Bryant Like » Thu, 04 Jul 2002 05:34:05



Quote:> What is the best way to retrieve XML from a select statement using FOR XML
> into a variable in VB?

One example of using VB is given here:
http://sqlxml.org/faqs.aspx?faq=1

--
Bryant

 
 
 

1. Problem using VB to retrieve ASP/XML using ADO recordset

Hello,

I've read about ADO url recordset connections, but somehow can't get
this simple example working:

Dim strConnection               As String
Dim myRecordset                 As ADODB.Recordset

Set myRecordset = New ADODB.Recordset
myRecordset.Open "http://computercity.dyndns.org/test.xml", , _
                  adOpenStatic, adLockBatchOptimistic

myRecordset.Close
Set myRecordset = Nothing

The ASP referenced above is a simple XML file as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
</note>

When running the VB app, following error occurs on the myRecordset.Open
command line:

Run Time Error 3709 - The connection cannot be used to perform this
operation. It is either closed, invalid or incorrect.

I have tried opening an ADODB.connection first and inserting this one in
the recordset.open line, but no success.

Please help!!!

Regards,
Kris

2. Formatting with the "update" command

3. retrieve XML data from SQL server by using XSD mapping schema

4. layout question

5. Retrieve XML data using SQLXML through URL within stored procedure

6. Cross platform databse?

7. Using OLEDB Templates to Retrieve XML Data Through XPath Query

8. Cursors

9. Retrieving Data using For XML

10. Retrieve XML data using SQLXML through URL within stored procedure

11. Using an ADO stream to retrieve xml data from remote website

12. Problems with retrieving data using FOR XML EXPLICIT

13. retrieve XML data from SQL server by using XSD mapping schema