views:

253

answers:

5

hi i want to import my .xml file to sql server database in asp.net 3.5 c# for windows application.so give m rply as fast as posible.

A: 

Sorrry, I am also facing this problem if you got any solution than please inform me

Bhavesh
SO isn't a forum; please, delete this "answer" and, if you wish, make this question as favorite to get follow ups.
Rubens Farias
A: 

It's not brilliant, but you could read an XML file into a dataset and then use a data adapter to then populate the database...that would require very few lines of code, but not something you'd really want to hold onto...more of a once off dataload.

davidsleeps
+3  A: 

this might help you http://support.microsoft.com/kb/316005

this code snippet might be helpful

     DataSet reportData = new DataSet();
  reportData.ReadXml(Server.MapPath(”report.xml”));

 SqlConnection connection = new SqlConnection(”CONNECTION STRING”);
SqlBulkCopy sbc = new SqlBulkCopy(connection);
  sbc.DestinationTableName = “report_table”;

   //if your DB col names don’t match your XML element names 100%
  //then relate the source XML elements (1st param) with the destination DB cols
sbc.ColumnMappings.Add(”campaign”, “campaign_id”);
sbc.ColumnMappings.Add(”cost”, “cost_USD”);

connection.Open(); 

refer http://www.akamarketing.com/blog/135-importing-xml-into-sql-server-table-aspnet.html

GK
A: 

first u ve 2 manipulate d xml file using an xml parser, so that the elements in the xml document converts into objects that can be accessed by other applications

Arun Chand
A: 

If this is something you are doing that is considered to be preprocessing, I would consider using SSIS: Import XML to SQL Server

rfonn