Importing data to MS SQL Server using SqlBulkCopy

Source: Internet
Author: User
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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.