ASP.NET 更新语句
cmd.CommandText = "update detailesid set num=num+1 where id=" + id + " and detailesid= "+ RadioButtonList1.SelectedValue.ToString();
cmd.ExecuteNonQuery();
我做了一个投票程序,这个是在BUTTON里的代码
我运行一下说我 = 附近有错误,我想让大家看看整个更新语句对吗?
先找个查询分析器运行一次,没错的话就是 值的问题了.
先在sql里面运行一次!!
添加监视,追踪出这句sql 你在查询分析器里面运行看看会不会有问题
id值是否正确
string sql="update detailesid set num=num+1 where id=" + id + " and detailesid="+ RadioButtonList1.SelectedValue.ToString();
调试看看是否正确
cmd.CommandText = "update detailesid set num=num+1 where id=" + id + " and detailesid="+ RadioButtonList1.SelectedValue.ToString();
id和detailesid的类型,是否需要加单引号
5楼正解
"update detailesid set num=num+1 where id=" + id + " and detailesid= "+ RadioButtonList1.SelectedValue.ToString();
这个应该是表名吧,是不是弄错了, 后面也相同的?
cmd.CommandText = "update detailesid set num=num+1 where id=" + id + " and detailesid= "+ RadioButtonList1.SelectedValue.ToString();
调试看一下这个语句,应该是这里的问题
更多的是要注意前后空格的问题
cmd.CommandText = "update detailesid set num=num+1 where id=" + id + " and detailesid= "+ RadioButtonL
相关问答:
我在一个ASPX页面中用 <!-- #include file="top.asp"-->嵌套了一个asp页面,但在点击按钮提交表单的时候没有任何反应,是不是两个FORM的原因造成的,top.asp里面也有一个form,把嵌套去掉的话,运行 ......
我用C#编asp.net网页。在一个按钮button1中,有一段代码运行时间较长,于是我想在按钮按下之后,用一个label1来显示一小段字符:label1.text="正在查询中,请稍等...",然后在button1代码执行的最后一行代 ......
C# code:
string sql = "select * from userinfo where uname = '" + uname + "' and upassword = '" + upassword + "'";
//和
string sql = "select * from userinfo where ......
如题:前几天服务器还是好好的 今天网页打不开突然出现错误,一查是链接不上数据库了?
(查询分析器和企业管理器都可以正常显示)
[SqlException (0x80131904): 用户 'sa' 登录失败。]
......