读书人

“System.Data.SqlClient.SqlExceptio

发布时间: 2012-03-09 21:42:54 作者: rapoo

“System.Data.SqlClient.SqlException”类型的未经处理的异常出现在 System.Data.dll 中。 求解释。。。

C# code
                        druser.Dispose();                         SqlCommand cmdTime = new SqlCommand("select datediff(hour,firsttime,GETDATE()) FROM tb_user where usernum='" + str + "' ", con);                        textBox1.Text = cmdTime.ExecuteScalar().ToString();                        int sj = Convert.ToInt32(textBox1.Text);                        SqlCommand cmdclear = new SqlCommand("updata tb_user set firsttime='" + now + "',sum=sum+sj where usernum='" + str + "'", con);                        cmdclear.ExecuteScalar();/*运行到这时出现  “System.Data.SqlClient.SqlException”类型的未经处理的异常出现在 System.Data.dll 中。其他信息: '=' 附近有语法错误。*/                        con.Close();


[解决办法]
sum 在数据库什么类型
[解决办法]
select datediff(hour,firsttime,GETDATE()) FROM tb_user where usernum='" + str + "' "
sql出问题了,看看str 是什么
[解决办法]
updata tb_user set firsttime='" + now + "',[sum]=[sum]+sj where usernum='" + str + "'"
[解决办法]
update 写错了
[解决办法]
自己不细心
[解决办法]
探讨
update 写错了

读书人网 >C#

热点推荐