|
数据是从数据库读出到datatable然后在窗口底部添加合计项
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;
上面代码中objSum是要来计算合计的
但无论我的
selectCommand="select ID,GXID,GXname,GXprice from WS_GX where ProductID=1";
还是
selectCommand="select ID,GXID,GXname,GXprice from WS_GX";
合计项的值都是按照数据库中所有项目加起来,导致合计错误,应该如何解决啊???? |
|