Bulk INSERT, I used to build a bunch of INSERT into SQL statements, and then use the program value row, to implement.
Today I saw ASP. You can use a DataTable, write data to a DataTable, and then use the SqlBulkCopy method to pass him a DataTable type, which automatically implements bulk insertions.
The speed is extremely fast.
Practice note here for future reference
protected voidButton1_Click (Objectsender, EventArgs e) { //prepare the data for bulk insertionDataTable table =NewDataTable (); Table. Columns.Add (" Age"); Table. Columns.Add ("Name"); DataRow Row=table. NewRow (); row[" Age"] = -; row["Name"] ="Jack"; Table. Rows.Add (row); DataRow Row1=table. NewRow (); row1[" Age"] = in; row1["Name"] ="Fei"; Table. Rows.Add (ROW1); stringConnectionStr ="server=.; database=demo;uid=sa;pwd=123456"; using(SqlBulkCopy bulkcopy =NewSqlBulkCopy (CONNECTIONSTR)) {Bulkcopy.destinationtablename=" Person";//in the inserted target table//Mapping of DataTable column names to database column namesBULKCOPY.COLUMNMAPPINGS.ADD (" Age"," Age"); BULKCOPY.COLUMNMAPPINGS.ADD ("Name","Name"); Bulkcopy.writetoserver (table);//writing to the database} Response.Write ("OK"); }
ASP. NET BULK Insert using SqlBulkCopy