BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


SQL XML
How to transfer XML into a plain text file?
Convert XDR to XML
Sort a table using the header of the table
Applying a XSLT stylesheet using the DBMS_XMLQuery package
N:N relationships with DBMS_XMLQuery Package
DBMS_XMLQuery package bind values to produce more than one xml file
Download data from a database in XML
Inserting XML file into a table using DBMS_XMLSave Package
Insert XML file into a table using ADO
How to call out to a COM component's method through XSLT
How to select DISTINCT items from XML via XSLT
How to convert Word (RTF) documents to XML for auto publication
Creating SQL Statements with XSLT
SQL straight to XML w/ transform
History Of XML
History Of XML And What Is XML.
Order Automation
You enjoy while you are away and let your machine do the job for you.
SQL Server 2000 User Defined Functions - A Powerful concept
XML/XSLT Maker


 
 

<< SEOSystem.XML >>


By Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First Posted 08/31/2001
Times viewed 3799

How to use the ADO Stream object to retrieve SQL2000 XML


Summary The following snippet explains how to use the ADO stream object to retrieve your FOR XML stored procedures.

So often you read about how to retrieve your FOR XML queries with the new SQL 7/2000 HTTP settings.  But this method exposes your database and does not have tight security.

Using the ADO Stream object is really fast and is hidden in your VB/ASP code

The following code comes from my good friend and co-worker Brandon Driessen who is excellent at using the new FOR XML syntax.

Firstly set up your ADO command object, adding your parameters, etc.

To set up your ADO stream, to return your XML string from SQL 2000, use the following:

Set oStream = New ADODB.Stream
oStream.Charset = windows-1252
oStream.Open
oCommand.Properties(Output Stream) = oStream

               
oCommand.Execute , , adExecuteStream
oStream.Position = 0
sXML = oStream.ReadText
oStream.Close


You use the 'Properties' property to indicate to the Command object that you want the stored procedure to be passed back into a Stream object, instead of a Recordset.

To prevent unusual characters, you will notice that we are setting which encoding the ADO stream should returned for the XML format.

Additional information


Rate this article on a scale of 1 to 10 (1 votes, average 5)

Your vote :  

<< SEOSystem.XML >>





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML