kloepper

kloepper

  • NA
  • 4
  • 0

Trouble passing XML string to OpenXML SPROC

May 26 2005 9:40 PM
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;database=MyDatabase"); SqlCommand sCmd01 = new SqlCommand("_sp_Insert_Form_004_XML_template_07",sCon01); sCmd01.CommandType = CommandType.StoredProcedure; sCmd01.Parameters.Add("@Form_004",SqlDbType.NText).Value = xmlDoc; sCmd01.Connection.Open(); sCmd01.ExecuteNonQuery(); sCmd01.Connection.Close();

Answers (1)