StrataFrame Forum

How to save a Xml-File on SQL-Server

http://forum.strataframe.net/Topic22356.aspx

By Rainer Kempf, RK - 3/13/2009

Hi,



I have follwing probelm.



I have a table on sqlserver with a field of type XML



in BO i changed Datatype of this field to System.Data.SqlTypes.SqlXml



this is code for saveing XML on SQL-Server :







If File.Exists(LcFileName) Then



Dim loXMLDocument As XmlDocument = New XmlDocument

loXMLdocument.Load(LcFileName)

loXML = New SqlXml(New XmlTextReader(loXMLdocument.InnerXml, XmlNodeType.Document, Nothing))



GridConfigBo1.layoutxml = loXML



GridConfigBo1.Save()





End If







When Record not exist on SQL-Server then Record will be saved.



Next time when i try to update XML-Field i got error message. (Translated error message)



The XML Datatyp can be only compared or sorted with the is null operator.





what did i wrong ???



Thanks



Rainer
By Trent L. Taylor - 3/14/2009

This will be impossible to tell without a sample and the actual XML data.  When using an XML data type on SQL Server, you MUST have the xml properly formatted and provide a schema otherwise it will fail.  The XML data type is pretty cool if you get it working as you can query within the XML string...however, this is not a forgiving data type.  Why are you using the Xml data type instead of a VarChar or NVarChar fiield?