Link to home
Create AccountLog in
Avatar of CipherIS
CipherISFlag for United States of America

asked on

C# Store XML in SQL database via .NET

I want to store XML in SQL Database using .NET with a class

Structure would be something like

<Settings>
<Key>abc</key><Value>123</Value>
<Key>abcd</key><Value>1234</Value>
</Settings>
<Object>
    <car>
       <make>Camaro</make>
       <year>1979</year>
   </car>
    <car>
       <make>Corvette</make>
       <year>1975</year>
   </car>
</Object>
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

SQL has an xml datatype column or you can store it as a varchar.
Avatar of CipherIS

ASKER

Yes, I know it has an XML datatype column.
And your question is then ?
How to store XML data in SQL Server via .NET as I stated above with my example.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thanks I found below example to pass the XML via .NET to SQL Server.

http://www.morgantechspace.com/2014/05/How-to-Store-and-Read-CSharp-Class-Object-into-Sql-Server.html