1. large data volume operations can use the SqlBulkCopy class to quickly write large data volumes. for SQL Server optimization, DataRow data, DataTable, and DataReaderWriteToServer (DataTable) can be written to the data table WriteToServer (DataRow []). batch write data row WriteToServer (DataTable,
1. large batch data operations can use the SqlBulkCopy class to quickly write large batch data. for SQL Server optimization, DataRow data, DataTable, DataReader WriteToServer (DataTable) can be written) write Data Table WriteToServer (DataRow []) write data rows in batches WriteToServer (DataTable,
1. Large
Batch
Data
Operation
You can use the SqlBulkCopy class to quickly write large data
Batch
DataFor SQL Server optimization, DataRow can be written.
Data, DataTable, DataReader
WriteToServer (DataTable) Write
DataTable
WriteToServer (DataRow []) Batch write
DataLine
WriteToServer (DataTable, DataRowState) write data by row
DataDatabase Table
WriteToServer (IDataReader) writes a DataReader object
String Connstr = " Server = (local); database = northwind; integrated security = true; async = true " ;
// Fill up a DataSet
DataSet ds = New DataSet ();
SqlConnection conn = New SqlConnection (connstr );
SqlDataAdapter dadp = New SqlDataAdapter ( " Select * from MERs " , Conn );
Dadp. Fill (ds );
// Copy the Data to SqlServer
SqlBulkCopy bcp = New SqlBulkCopy (connstr );
Bcp. DestinationTableName = " Customers1 " ;
Bcp. WriteToServer (ds. Tables [ 0 ]);
2. Multiple
DynamicOf
ResultSet
Multiple Active Result Sets (MARS)
This can only be used in SQL Server 2005
Multiple DataReader can be opened simultaneously on a Command object
String Connstr = " Server = (local); database = northwind; integrated security = true; async = true " ;
SqlConnection conn = New SqlConnection (connstr );
Conn. Open ();
SqlCommand cmd1 = New SqlCommand ( " Select * from MERs " , Conn );
SqlCommand cmd2 = New SqlCommand ( " Select * from orders " , Conn );
SqlDataReader rdr1 = Secrets 1.executereader ();
// Next statement causes an error prior to SQL Server 2005
SqlDataReader rdr2 = Other 2.executereader ();
// Now you can reader from rdr1 and rdr2 at the same time.