|
The data is read from the database to the datatable and then added totals at the bottom of the window
string selectCommand = "select ID, GXID, GXname, GXprice from WS_GX where ProductID = 1";
dataAdapter = new OleDbDataAdapter (selectCommand, conn);
DataSet ds = new DataSet ();
dataAdapter.Fill (ds, "WS_GX");
DataTable table = ds.Tables ["WS_GX"];
object objSum = table.Compute ("Sum (GXprice)", null);
bindingSource1.DataSource = table;
In the above code, objSum is used to calculate the total
But whatever
selectCommand = "select ID, GXID, GXname, GXprice from WS_GX where ProductID = 1";
still is
selectCommand = "select ID, GXID, GXname, GXprice from WS_GX";
The value of the total item is added up according to all the items in the database, which causes the total error. How can I solve it ???? |
|