My requirement is to read a XML string, Manipulate and store it in MS SQL Server.
XML:
...
...
...
...
its available in string
string sXML = "
"
MS SQL Server table structure and xml mapping
MyTable - XML
Column1->Col1
Column2->Col2
Column3->Col3
Column4->Col1+Col2
Column5->Col3+200
Column6-> {current system date}
Column-> {Default constraint stores '0' always}
Number of rows inserted will be max of 100 rows at a time
current clients accessing this app and passing XML would be around 20
Frequency of calling is 1 min
I use .NET 4.0, C# and MS SQL Server 2008
My Approach is read, xml file, manipulate it, store in dataset/datatable and do the bulk copy.
My Question is :
1. In this approach, How to manipulate and store it in dataset/datatable
1. Is there any better way to do it?
Thank you.
Posted Aug 29, 2013, 1:01 AM
http://www.c-sharpcorner.com/Blogs/11481/serialize-objects-in-custom-xml-format-using-xml-serializati.aspx
Posted Aug 28, 2013, 7:58 PM
Try the following code.
* First load the xml into dataset
* Extract the datatable from the dataset
* Add the required or the computational columns. You can use expression property to aggregate / sum / to create computed columns.
* Use the default value property for the datetime and for the column 7.
* Send the datatable to sqlbulk load class to insert into database.
You can use SQL bulk load to insert the records into sql server. That will be faster.
Please let me know, if you need further information.