读书人

数据库求和有关问题

发布时间: 2014-01-17 00:06:00 作者: rapoo

数据库求和问题
数据库求和有关问题数据库求和有关问题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

读书人网 >C#

热点推荐