Sort datatable:
Datarow [] DR = DT. Select ("A0 is not null", "A0 ASC ");
Datatable dt1 = DT. Clone ();
Dt1.rows. Clear ();
For (I = 0; I <DT. Rows. Count; I ++)
{
Datarow irow = dt1.newrow ();
For (Int J = 0; j <DT. Columns. Count; j ++)
{
If (Dr [I] [J]! = NULL)
If (Dr [I] [J]. tostring ()! = "")
Irow [J] = Dr [I] [J]. tostring ();
}
Dt1.rows. Add (irow );
}
Return dt1;
Split the datatable:
Private string datatable (datatable DT)
{
Int dtindex = DT. Rows. Count; // retrieves the total number of DT rows.
Int Index = 0, I = 0, Index = 0; // index indicates the number of data rows.
String datarow, err = "";
Datarow = DT. Rows [0] [0]. tostring (); // retrieve the ticket number of the first record
// If the total number of rows is not equal to 0
Sqlconnection con = new sqlconnection (sqlhelper. toeposconnstring );
Con. open ();
While (dtindex! = Index) // 11
{
Datarow [] DR = DT. Select ("a0 = '" + datarow. tostring () + "'"); // retrieve the total number of ticket numbers
Index = dr. length; // The number of rows from the new dr.
Datatable dt1 = DT. Clone ();
Dt1.rows. Clear ();
For (I = 0; I <index; I ++) // Add the new row to the new able.
{
Datarow irow = dt1.newrow ();
For (Int J = 0; j <DT. Columns. Count; j ++)
{
If (Dr [I] [J]! = NULL)
If (Dr [I] [J]. tostring ()! = "")
Irow [J] = Dr [I] [J]. tostring ();
}
Dt1.rows. Add (irow );
}
Err = inserttodatabase (dt1, con); // call the method to write the values in the new able into the database
Index = index + index;
If (Index = dtindex)
Break;
Datarow = DT. Rows [Index] [0]. tostring ();
}
Con. Close ();
Return err;
}