locked
Sql server 2005 passing XML from .net 2008 RRS feed

  • Question

  • Hi,

    I am passing a XML document from .net to Sql server 2005 , my goal is to unwrap the XML file and insert those values into a temp table. i am getting error when i am doing it so.

    here is my piece of code what i have written in .net

     

    SqlParameter paramXML = new SqlParameter("@Xml", SqlDbType.Xml);

    paramXML.Value = dsTemp.GetXml();


    My stored procedure is

    CREATE

     

    PROC TEMPXML

    @XML

    xml

    as

    select

     

    @xml="<NewDataSet>\r\n <Struc>\r\n<Age>20</Age>\r\n <Gender>F</Gender>\r\n <Membert>2</Member>\r\n <Net>SC</Net>\r\n <Count>0</rCount>\r\n <City>C</City>\r\n <Team>3</Team>\r\n </Struc>\r\n</NewDataSet>"

    DECLARE

     

    @hDoc INT

    exec

     

    sp_xml_preparedocument @hDoc output, @xml

     

    when i tried to parse it, an error

    Maximum length is 128

     

    was thrown.

    Please help me out and let me know whether the XML cannot withhold bulk data or i am goin somewhere wrong??

    Wednesday, December 23, 2009 9:59 PM

All replies

  • I have ran this proc and it created successfully, below is the tsql statment

    CREATE PROC TEMPXML 
    @XML xml 
    as
    select @xml='<NewDataSet>\r\n <Struc>\r\n<Age>20</Age>\r\n <Gender>F</Gender>\r\n <Membert>2</Member>\r\n <Net>SC</Net>\r\n <Count>0</rCount>\r\n <City>C</City>\r\n <Team>3</Team>\r\n </Struc>\r\n</NewDataSet>'
    DECLARE @hDoc INT 
    exec sp_xml_preparedocument @hDoc output, @xml 
    

    Vidhya Sagar. Mark as Answer if it helps!
    Thursday, December 24, 2009 2:31 AM
  • thanks for your response. But i am getting this error when i tried to run this

    XML parsing: line 1, character 87, end tag does not match start tag

    Thursday, December 24, 2009 3:45 AM