DataTable dtprobaselist = new DataTable ("Dtprobaselist");
DTPROBASELIST.COLUMNS.ADD ("Id", Type.GetType ("System.String"));
DTPROBASELIST.COLUMNS.ADD ("ProductId", Type.GetType ("System.String"));
DTPROBASELIST.COLUMNS.ADD ("Cname", Type.GetType ("System.String"));
DTPROBASELIST.COLUMNS.ADD ("Barcode", Type.GetType ("System.String"));
DataTable dtexams = new DataTable ("Dtexams");
DTEXAMS.COLUMNS.ADD ("Id", Type.GetType ("System.String"));
DTEXAMS.COLUMNS.ADD ("Flowproid", Type.GetType ("System.String"));
DTEXAMS.COLUMNS.ADD ("ProductId", Type.GetType ("System.String"));
DTEXAMS.COLUMNS.ADD ("Cname", Type.GetType ("System.String"));
DataColumn KeyColumn = dtprobaselist.columns["Id"];//get primary key
Keycolumn.unique = true;
Keycolumn.allowdbnull=false;
Keycolumn.autoincrement = true;//Auto-Grow
Keycolumn.autoincrementseed = 0;//Start value
Keycolumn.autoincrementstep = 1;//Increment
DataColumn foreignkeycolumn = dtexams.columns["flowproid"];//foreign key
DataSet ds=new DataSet ();
Ds. Tables.add (dtprobaselist);//Add Table
Ds. Tables.add (Dtexams);
Ds. Relations.Add ("Productexam", KeyColumn, Foreignkeycolumn);//Building relationships
Calculate statistics
//
Summary:
Calculates the given expression on the current line that is used to pass the filter condition.
//
Parameters:
Expression
The expression to evaluate.
//
Filter
The filter to limit the rows that are evaluated in an expression.
//
return Result:
System.Object, set to the calculated result.
public object Compute (string expression, string filter);
1. Sum of one column
Eg summation: sel=1 and payment_type= ' 2 ' and
Decimal. TryParse (dsproductlist.tables["Nopay"). Compute ("sum (AMOUNT)", "sel= ' 1 ' and payment_type= ' 2 '"). ToString (), out selfpay);
2. Totals for multiple columns
DataRow Drarr[]=null;
Drarr.sum (p = p.field<decimal> ("Discountprice") * p.field<int32> ("Count"))
Basic usage of DataTable day1