469,904 Members | 2,074 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

Trouble passing XML string to OpenXML SPROC

a
I'm trying to pass an xml file as a variable of type string to an OpenXML
stored procedure, but the code below fails at the "sCmd01.ExecuteNonQuery();"
line. The SPROC is working fine in Query Analyzer.

Anyone know how to make this work?

Thanks,

Paul

the error code is:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred
in system.data.dll

Additional information: System error.
===========================================

string XMLDoc = "D:\\SEC\\Programming\\SEC DataBots\\SEC DataBot Test
Files\\Form 4\\From QS.xml";
StreamReader srXML = new StreamReader(XMLDoc);
string xmlDoc = srXML.ReadToEnd();
SqlConnection sCon01 = new
SqlConnection("server=AMD;Trusted_Connection=yes;d atabase=MyDatabase");
SqlCommand sCmd01 = new
SqlCommand("_sp_Insert_Form_004_XML_template_07",s Con01);
sCmd01.CommandType = CommandType.StoredProcedure;
sCmd01.Parameters.Add("@Form_004",SqlDbType.NText) .Value = xmlDoc;
sCmd01.Connection.Open();
sCmd01.ExecuteNonQuery();
sCmd01.Connection.Close();

Nov 17 '05 #1
1 2436
a
OK...I didn't validate the test document...it turns out to have an error in it.
The code I've been using is actually ok--except that it needs to also
validate the files.

Paul
---------------------------------------------------------------

"a" wrote:
I'm trying to pass an xml file as a variable of type string to an OpenXML
stored procedure, but the code below fails at the "sCmd01.ExecuteNonQuery();"
line. The SPROC is working fine in Query Analyzer.

Anyone know how to make this work?

Thanks,

Paul

the error code is:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred
in system.data.dll

Additional information: System error.
===========================================

string XMLDoc = "D:\\SEC\\Programming\\SEC DataBots\\SEC DataBot Test
Files\\Form 4\\From QS.xml";
StreamReader srXML = new StreamReader(XMLDoc);
string xmlDoc = srXML.ReadToEnd();
SqlConnection sCon01 = new
SqlConnection("server=AMD;Trusted_Connection=yes;d atabase=MyDatabase");
SqlCommand sCmd01 = new
SqlCommand("_sp_Insert_Form_004_XML_template_07",s Con01);
sCmd01.CommandType = CommandType.StoredProcedure;
sCmd01.Parameters.Add("@Form_004",SqlDbType.NText) .Value = xmlDoc;
sCmd01.Connection.Open();
sCmd01.ExecuteNonQuery();
sCmd01.Connection.Close();

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by mirza i | last post: by
4 posts views Thread by Driesen via SQLMonster.com | last post: by
1 post views Thread by John Hoge | last post: by
4 posts views Thread by Chad Micheal Lawson via .NET 247 | last post: by
reply views Thread by Micke | last post: by
5 posts views Thread by Tim::.. | last post: by
2 posts views Thread by Shilpa | last post: by
2 posts views Thread by Lauren Quantrell | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.