First, establish the student table in the database
Ii. creation of 100,000 data
Create Data
Iii. creating a general data storage method
PublicStaticvoidSavegeneral (DataTable DT) {String strconn =@"Data Source=.;i Nitial catalog=test;integrated Security=true"; SqlConnection conn =NewSqlConnection (strconn); Conn. Open (); SqlCommand cmd =NewSqlCommand (); Cmd. Connection =Connfor (int i =0; i < dt. Rows.Count; I++) {string strSQL = insert into [Test]. [dbo]. [Student] VALUES (' ' + dt. Rows[i][0 "+ " "+ dt. Rows[i][1 "+ " "+ dt. Rows[i][ ") " Cmd.commandtext = strSQL; cmd. ExecuteNonQuery (); } conn. Close (); }
Iv. Creating bulk storage data
To establish a mapping relationship between a data source and a destination storage data structure:
Relational Mappings
Create transaction Store bulk data:
Bulk Storage
Summarize:
There is a big difference in the time between the two storage methods.
My PC's configuration CPU 3.40GH identify memory 3.4G
Storing 10W data in general storage methods takes about 8 minutes and 57 seconds.
Takes approximately 1.9503 seconds to store 10W of data in a sqlbulkcopy batch
Comparison of general data storage and bulk data storage--100,000 data