RE: Trouble passing XML string to OpenXML SPROC



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();
>
.



Relevant Pages

  • Re: JMS: Re: Babylon 5 Universe Novels?
    ... >Carved in mystic runes upon the very living rock, the last words of Paul ... >"...there is no Earthly reason for me to read any more of the drivel ... Hoping we'll validate your ... >> You do that by replying. ...
    (rec.arts.sf.tv.babylon5.moderated)
  • RE: Is XSD schema flexible?
    ... > configuration and other data in the XML file. ... I want each time app opens XML ... > file to validate the file against scheme. ... Should I use XSD schema validation at all? ...
    (microsoft.public.dotnet.xml)
  • Re: parsing XML file
    ... I've got an XML file, ... Schema file I have. ... How can I validate the XML file with my XSD Schema? ...
    (comp.lang.java.programmer)
  • XmlValidatingReader: continue parsing after XmlException
    ... When attempting to validate an XML file, If the file is valid, it ... I keep getting the following Exception: ... With a try-finally block, I want to easily be able to get ...
    (microsoft.public.dotnet.xml)
  • Re: How to validate a query?
    ... Could you perhaps e-mail them to my direct e-mail. ... >> Hi Paul, a stored procedure is not the right place from which to ... >> If the TSQL batch does not validate, ... > rights. ...
    (microsoft.public.sqlserver.programming)