请各位好心人帮帮我,谢谢
我在数据库中有几行,我想把某列的值做加法,再显示到Label中,相加我会,但是不知道怎么显示在Label中,我是用C#的,不知道谁能帮我一下,谢谢
string sql = "select sum(price) from tr where usersname= ' " + Session[ "logusername "].ToString() + " ' ";
OleDbCommand cmd = new OleDbCommand(sql, conn);
接下来代码该怎么写呢?
------解决方案--------------------string str=cmd.ExecuteScalar().ToString();
------解决方案--------------------this.label1.text=cmd.ExecuteScalar().tostring();
------解决方案--------------------object obj = cmd.ExecuteScalar();
if (obj != DBNull.Value)
{
string ret = obj.ToString();
}
------解决方案--------------------label1.text=cmd.ExecuteScalar().tostring();