RE: Trouble passing XML string to OpenXML SPROC
- From: "a" <a@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 26 May 2005 21:04:06 -0700
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;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();
>
.
- References:
- Prev by Date: Re: what's the point of an interface?
- Next by Date: Re: what's the point of an interface?
- Previous by thread: Trouble passing XML string to OpenXML SPROC
- Next by thread: keyword this
- Index(es):
Relevant Pages
|