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.
Asked
Active
Viewed 2,209 times
-1
-
Are you interested in saving file into xml column ? – Asad Jan 22 '10 at 13:25
-
hope you won't mind re tagging as your question states "windows application" which was confusing with previous tag "asp.net" – Asad Jan 22 '10 at 13:28
4 Answers
2
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

GuruKulki
- 25,776
- 50
- 140
- 201
0
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
- 9,393
- 11
- 59
- 73
0
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
0
If this is something you are doing that is considered to be preprocessing, I would consider using SSIS: Import XML to SQL Server

rfonn
- 2,161
- 12
- 8