1. Massive Data Operations
You can use the sqlbulkcopy class to quickly write large volumes of data. for SQL Server optimization, you can write datarow data, datatable, datareader
Writetoserver (datatable) write data table
Writetoserver (datarow []) Batch write data rows
Writetoserver (datatable, datarowstate) writes data to the database table by row
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 Dynamic result sets
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.