• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

best approach to integrate csv/xml data to db

hi, what is the best approach in c# to integrate data, from csv or xml, to db.
any example you can point out?
0
johndenny
Asked:
johndenny
  • 3
  • 2
2 Solutions
 
mrjoltcolaCommented:
Load the XML into a DataSet, then traverse the DataTables in the DataSet and insert the records into the database. DataSet and DataTable have methods for loading XML. It is then straightforward to read the schema from each DataTable (table.Columns) and access the records (table.Rows).
0
 
dj_alikCommented:
Are you talking about SQL SERVER?
Examples of Bulk Importing and Exporting XML Documents
http://msdn.microsoft.com/en-us/library/ms191184
0
 
johndennyAuthor Commented:
I have to do it a c# program, then from there, bulkinsert to db, the rest is db. My question for mrjoltcola, if you have thousands of rows of csv/xml, loading it into datatable or dataset, isnt it heavy? can we have just list of a class or struct? which one better in this case List<SomeClass> or List<SomeStruct> or datatable or dataset? i want to make it sure fast and less memory usage, basically performance is no 1.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
dj_alikCommented:
Are you speaking about server side process?
If yes
Best Option ADO.NET SqlBulkCopy Class in C# yes with DataTable
http://www.codeproject.com/KB/database/SqlBulkCopy_in_ADONET.aspx


 
0
 
johndennyAuthor Commented:
yes server side, a program doing a job/task, i think sqlbulkcopy pretty much insert, with my data, i can update/insert too. I am not sure datatable is the best? compare to generic collection? List<Class> or List<Struct>?
0
 
dj_alikCommented:
SqlBulkCopy is only used for inserting records, not updating
You can insert by using it to temp table  with best performance and after that do want............ with stored procedures..............
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now