Solved

C# Store XML in SQL database via .NET

Posted on 2016-08-04
6
54 Views
Last Modified: 2016-08-04
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>
0
Comment
Question by:CipherIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 41742933
SQL has an xml datatype column or you can store it as a varchar.
0
 
LVL 1

Author Comment

by:CipherIS
ID: 41742942
Yes, I know it has an XML datatype column.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 41742951
And your question is then ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:CipherIS
ID: 41742973
How to store XML data in SQL Server via .NET as I stated above with my example.
0
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 41743044
update table set xml_column = '<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>'

Open in new window

0
 
LVL 1

Author Comment

by:CipherIS
ID: 41743081
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
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question