Original: Import data to MS SQL Server using SqlBulkCopy
Insus.net always uses the table type to data into MS SQL Server. Refer to "stored Procedure parameter for DataTable" http://www.cnblogs.com/insus/archive/2012/09/22/2698515.html. Learn a SqlBulkCopy today to import data into MS SQL Server.
This is the "Read XML node" http://www.cnblogs.com/insus/p/3778256.html, for example, the XML data into the database. Let's take a look at the structure of XML, which has two fields. Therefore, a database is required to create a table, the structure is the same as the XML structure, two fields, the two field names can be consistent with the import source field names, or inconsistent.
In. aspx, add a GridView with a button control that is used to display and execute the import event:
Bind the XML data to the Gridivew control:
The Ammonium button event, first declaring a DataTable variable, then looping the GridView control, populating the data into a DataTable, then connecting the data, specifying the Target data table (#50行代码), matching fields (#52 ~ #53).
Finally, open the connection, start writing to the database, and finally, close the connection.
Here is a demo of live operation: