1. Faster execution efficiency of the new index Engine
The following code takes 2003 seconds in 157 and 11 seconds in 2005: DataSet ds = new DataSet ();
Ds. Tables. Add ("BigTable ");
Ds. Tables [0]. Columns. Add ("ID", Type. GetType ("System. Int32 "));
Ds. Tables [0]. Columns ["ID"]. Unique = true;
Ds. Tables [0]. Columns. Add ("Value", Type. GetType ("System. Int32 "));
Cursor. Current = Cursors. WaitCursor;
DateTime datBegin = DateTime. Now;
Random rand = new Random ();
Int I, intValue;
DataRow dr;
For (I = 1; I <= 500000; I ++)
{
Try
{
IntValue = rand. Next ();
Dr = ds. Tables [0]. NewRow ();
Dr ["ID"] = intValue;
Dr ["Value"] = intValue;
Ds. Tables [0]. Rows. Add (dr );
}
Catch {}
}
Cursor. Current = Cursors. Default;
MessageBox. Show ("Elapsed Time:" + (DateTime. Now-datBegin). Seconds. ToString ());
MessageBox. Show ("count =" + ds. Tables [0]. Rows. Count. ToString ());
2. Dataset can be serialized as a binary file string connstr = "server = (local); database = northwind; integrated security = true; async = true ";
DataSet ds = new DataSet ();
SqlDataAdapter dadpt = new SqlDataAdapter ("select * from [order details]", connstr );
Dadpt. Fill (ds );
BinaryFormatter bf = new BinaryFormatter ();
FileStream fs = new FileStream (@ "c: \ xml1.txt", FileMode. OpenOrCreate );
Ds. RemotingFormat = SerializationFormat. Binary;
Bf. Serialize (fs, ds );
3. More Independent Datatable
DataTable Write XML
String connstr = "server = (local); database = northwind; integrated security = true; async = true ";
SqlDataAdapter dadpt = new SqlDataAdapter ("select * from [order details]", connstr );
DataTable dt = new DataTable ("Customer ");
Dadpt. Fill (dt );
Dt. WriteXml (@ "c: \ DataTable. xml", true );
Dt. WriteXmlSchema (@ "c: \ DataTableSchema. xml ");
DataTable Read XML StreamReader sr = new StreamReader (@ "C: \ DataTableSchema. xml ");
DataTable dt = new DataTable ();
Dt. ReadXmlSchema (sr );
Dt. ReadXml (new StreamReader (@ "c: \ dataTable. xml "));
This. Maid = dt;
DataTable Merge string connstr = "server = (local); database = northwind; integrated security = true; async = true ";
SqlDataAdapter dadpt = new SqlDataAdapter ("select * from MERs", connstr );
DataTable dt = new DataTable ("Customer ");
Dadpt. Fill (dt );
SqlDataAdapter dadpt1 = new SqlDataAdapter ("select * from MERs", connstr );
DataTable dt1 = new DataTable ("Customer1 ");
Dadpt1.Fill (dt1 );
Dt. Merge (dt1 );
This. Maid = dt;
DataTable Load DataReader string connstr = "server = (local); database = northwind; integrated security = true; async = true ";
SqlConnection conn = new SqlConnection (connstr );
Conn. Open ();
SqlCommand cmd = new SqlCommand ("select * from [order details]", conn );
SqlDataReader dr = cmd. ExecuteReader ();
DataTable dt = new DataTable ("Customer ");
Dt. Load (dr );
This. Maid = dt;