.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

bind xml file data into datatable

Posted By: Sunil     Posted Date: November 08, 2008    Points:2   Category :Windows Application
This ok to bind xml file data into datatable. but now how this datatable will bind with sql where we not now that in xml how much column is present or how much row is ableble in xml data.

have u know any solution about it.

i have practice about it, i find that, using Backbulkcopy method where its one properties like backbulkcopy.destinationtablename="";
in this properties we want to auto create table and its column accourding to xml data column.

please have u any suggestion about it.........!

in C#.net

Author: Amit Mehra             
Posted Date: November 08, 2008     Points: 5   

ok..So why dont you create table first using SQL "Create Table..." the assign the table name

backbulkcopy.destinationtablename="Your table name".

Step wise

1) Load XML into DataSet using ReadXml method eg ds.ReadXml(xMLfilePath);

2) Get Table name from dataset like this ds.Tables[0].TableName or you can assign your own table name

3) Get Column name from dataset tables like thisds.Tables[0].Columns which will return you column collection .the you can loop this collection and get the column name like this ds.Tables[0].Columns[0].ColumnName.

4) then now you have Table name and column name you can create Tables using SQL Query then

5) Using BulkCopy you can save the xml data into Table.

Hope this will help you.

Please "Mark As Answer " if this post help you.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend