数据库求和问题
public string ZongYing(string id)
{
rint = 0;
rint1 = 0;
DataTable m_mdt = myData.GetDataTable("select sum(Score) as ka from RecordDrawScore where userID='" + id + "' and [InsertTime] >= '" + d1 + " 12:00:00' and [InsertTime] <= '" + d2 + " 12:00:00'");
if (m_mdt != null)
{
if (m_mdt.Rows[0][0].ToString() != "")
{
rint = rint + int.Parse(m_mdt.Rows[0][0].ToString());
}
A8位置是显示结果的,我怎么求和求不出来?
------解决方案--------------------把你的sql语句放数据库里看看有没有数据出来
select sum(Score) as ka from RecordDrawScore where userID='" + id + "' and [InsertTime] >= '" + d1 + " 12:00:00' and [InsertTime] <= '" + d2 + " 12:00:00