How to save a Xml-File on SQL-Server


Author
Message
Rainer Kempf, RK
Rainer Kempf, RK
StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)StrataFrame Novice (95 reputation)
Group: StrataFrame Users
Posts: 55, Visits: 1.4K
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

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search