修改页面时,SQL语句输入有误,请大家帮忙!!谢谢! "update 新闻 set '标题'='"+ TextBox1.Text + '" ,'内容'='"+ TextBox2.Text + "' ,'作者' ='"+ TextBox3.Text + "'where '编号' ="+ newsID); Response.Redirect("ManageNews.aspx"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 "update 新闻 set 标题='"+TextBox1.Text+"',内容='"+TextBox2.Text+"',作者='"+TextBox3.Text +"' where 编号="+newsID);如楼上所说去掉字段的单引号,还有就是单引号和双引号要对应起来 标题='"+ TextBox1.Text.ToString() + '" 使用中文字段名,一般用[]括起来。另外这样写的话,如果TextBox1、TextBox2、TextBox3中,有任意一个文本框为空的话,你这个sql语句会报语法错误,最好这样写:string sql = "update [新闻] set [编号]=[编号] ";if(TextBox1.Text.Trim().Length > 0) sql += ", [标题]='" + TextBox1.Text.Trim() + "' ";if(TextBox2.Text.Trim().Length > 0) sql += ", [内容]='" + TextBox2.Text.Trim() + "' ";if(TextBox3.Text.Trim().Length > 0) sql += ", [作者]='" + TextBox3.Text.Trim() + "' ";sql += " where [编号]=" + newsID; 如果是mssql,尝试使用,并过滤用户输入单引号:"UPDATE [新闻] SET [标题] = '" + TextBox1.Text.Replace("'", "''") + "' ,[内容] = '" + TextBox2.Text.Replace("'", "''") + "' ,[作者] = '" + TextBox3.Text.Replace("'", "''") + "' WHERE [编号] =" + newsID "update 新闻 set 标题='"+ TextBox1.Text + '" ,内容='"+ TextBox2.Text + "' ,作者 ='"+ TextBox3.Text + "' where 编号 ="+ newsID 楼主,你输出来一看不就知道错了吗?要不然就是楼主不太熟悉SQL语句吧,好像.net也刚入手吧,多看些基础的知识!string strSql ="update 新闻 set 标题='"+ TextBox1.Text + '" ,内容='"+ TextBox2.Text + "' ,作者 ='"+ TextBox3.Text + "' where 编号 ='"+newsID+"' "; 怎么在web显示直线? 保存下web.config就好了,似乎是缓存的问题 菜鸟请教窗体的点击事件问题 文件下载屏蔽弹出窗口 动态的添加用户的功能哪位高手给点思路提醒 关于dataset的增删改问题? Link button 不工作, 点击没法转向下一个页面 ####100分#### WINDOWS2008 R2x64位配置IIS出奇怪问题, 为Page加PreRender等事件应该怎么做呢? visual studio inherits不能够找到 asp.net条形码不能打印预览 京东网抢购器源码问题
如楼上所说去掉字段的单引号,还有就是单引号和双引号要对应起来
使用中文字段名,一般用[]括起来。
另外这样写的话,如果TextBox1、TextBox2、TextBox3中,有任意一个文本框为空的话,你这个sql语句会报语法错误,最好这样写:string sql = "update [新闻] set [编号]=[编号] ";
if(TextBox1.Text.Trim().Length > 0)
sql += ", [标题]='" + TextBox1.Text.Trim() + "' ";
if(TextBox2.Text.Trim().Length > 0)
sql += ", [内容]='" + TextBox2.Text.Trim() + "' ";
if(TextBox3.Text.Trim().Length > 0)
sql += ", [作者]='" + TextBox3.Text.Trim() + "' ";
sql += " where [编号]=" + newsID;
string strSql =
"update 新闻 set 标题='"+ TextBox1.Text + '" ,内容='"+ TextBox2.Text + "' ,作者 ='"+ TextBox3.Text + "' where 编号 ='"+newsID+"' ";