111,120
社区成员
发帖
与我相关
我的任务
分享-- 如果这样单个查询会对:
select [Cost] from Bank where ...
-- 那么这样求和就没问题,求和后列名还是 Cost:
select Sum([Cost]) as [Cost] from Bank where ...string sql = string.Format("select Sum([Cost]) as [Cost] from Bank where CardNo='{0}'", txtCard.Text.Trim());
// ...
float score = (float)datareader["Cost"];
// 或者:
float score = float.Parse(datareader["Cost"].ToString());
select Sum([Cost]) as [Cost] from Bank where CardNo='{0}'(float)datareader["Cost"];select Sum([Cost]) from Bank where CardNo='{0}'