Insus. NET always uses the table type to import data into ms SQL Server. Refer to stored procedure parameters as DataTable http://www.cnblogs.com/insus/archive/2012/09/22/2698515.html. Today, I learned a SqlBulkCopy file to import data to ms SQL Server.
For example, read a node of XML at http://www.cnblogs.com/insus/p/3778256.htmlto import xmldata to the data warehouse. Let's take a look at the xml structure. It has two fields. Therefore, the database needs to create a table with the same structure as the xml. The two fields can be the same or different names as the imported Source Field.
In. aspx, add a GridView and a Button control to display and execute import events:
Bind xml data to the Gridivew control:
The button event first declares a DataTable variable, then loops through the GridView control, fills the data in the DataTable, connects the data, and specifies the target data table (#50 lines of code ), matching field (#52 ~ #53 ).
The last step is to open the connection, start writing to the database, and close the connection.
The following is a real-time operation Demonstration: