
May 2nd, 2003, 05:58 PM
|
|
Registered User
|
|
Join Date: May 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Xml from a sql statment???
Hello I can not get the below code to work!!!! please help!!!!!!!!!!!!!!! What I am trying to do is pull data from a sql table but make it read as an xml file???????<br><br><br>void ExecuteXmlReaderDemo (string query, SqlConnection myConn) {<br>SqlCommand mySqlCommand = new SqlCommand (<br> "select firstname from userinfo FOR XML AUTO, XMLDATA", myConn);<br> string connString = <br> "SERVER=D1_PROD;database=Intranet;UID=NA;PWD=NA";<br> SqlCommand myCommand = new SqlCommand (query);<br> myCommand.Connection = new SqlConnection (connString);<br> <br> try {<br> myCommand.Connection.Open();<br><br> // set up dataset and fill with xml data.<br> DataSet myDataSet = new DataSet ();<br> myDataSet.ReadXml (myCommand.ExecuteXmlReader (), XmlReadMode.Fragment);<br><br> }<br> catch(Exception e) {<br> Response.Write (e.ToString ());<br> }<br> finally {<br> myConn.Close();<br> }<br>}
|