[thelist] Stored Proc to XML to Text File?

Casey Crookston caseyb at thecrookstons.com
Mon Mar 17 23:14:04 CDT 2008


Thanks!  I'll chew on this for a bit and ping you back if I have any 
trouble.

Casey

----- Original Message ----- 
From: "Anthony Baratta" <anthony at baratta.com>
To: <thelist at lists.evolt.org>
Sent: Monday, March 17, 2008 11:00 PM
Subject: Re: [thelist] Stored Proc to XML to Text File?


> You need to use the SqlXmlCommand to get the data returned as XML.
>
> Something like this (code based on SQLXML 3.0):
>
>             XmlDocument xd = new XmlDocument();
>             XmlReader xr;
>
>             try
>             {
>                 SqlXmlCommand cmd = new SqlXmlCommand(sConnectString);
>                 cmd.RootTag = <rootNodeName>;
>                 cmd.CommandType = SqlXmlCommandType.Sql;
>                 cmd.CommandText = sProcName
> + <any parameters the SP needs>;
>
>                 xr = cmd.ExecuteXmlReader();
>                 xd.Load(xr);
>             }
>             catch (Exception exp)
>             {
>                 DBError(exp, "execSPForXML: SqlXmlCommand /"
> + "cmd.ExecuteXmlReader (" + sProcName + ")");
>                 return xd;
>             }
>             return xd;
>
> Note you will need to prepend "Provider=SQLOLEDB;" to your connection
> string for the SQLXML 3.0 methods.
>
> This example returns an XmlDocument, that you can then write to the hard
> drive or do with what you will.
>
> Hope this gets you in the right direction.
>
>
> --
> Anthony Baratta
>
> "A government that is big enough to
> give you all you want is big enough
> to take it all away."
> --Barry Goldwater
> -- 
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt ! 




More information about the thelist mailing list