易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关问答:

asp.net嵌套一个asp页面后出现的问题

我在一个ASPX页面中用 <!-- #include file="top.asp"-->嵌套了一个asp页面,但在点击按钮提交表单的时候没有任何反应,是不是两个FORM的原因造成的,top.asp里面也有一个form,把嵌套去掉的话,运行 ......

ASP.NET代码是否可以保密

例如有两段代码
FirstPageCodeBehind.aspx
HTML code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FirstPageCodeBehind.aspx.cs" Inherits="FirstPag ......

asp.net 中图片拼接

我在asp.net中我要将四张或四张以下的图片拼在一起,如何实现?图片是我从数据库中读出来的二进制。单张读出来的代码如下:C# code:
DataHelper dh=new DataHelper();
System.Drawing.Image image = dh.g ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号