(第一次做软件)大家帮忙看看,刚学用vs2010 C#做软件,出现一行有语句错误,请大家帮忙找出来,就一行代码!!

u010524195 2014-11-12 09:18:36
int Rtn = db.ExecuteNonQuery("update sc set grade='" + this.textBox3.Text + "' where sno=" + this.textBox1.Text + "cno='" + this.textBox2.Text);
...全文
160 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
shoppingli 2014-11-13
  • 打赏
  • 举报
回复
上面都给答案,sql的条件少and,后面的cno = '"+this.textBox2.Text+"'",这里要注意单引号,如果是字符串的才使用,不是的就去掉,你自己看都看不清楚。 另外,你做软件,可以自己用单步调试,看一下sql语句出什么问题。自己先在数据库里面执行看看错误
u010524195 2014-11-13
  • 打赏
  • 举报
回复
非常感谢大家!!
zhrongr 2014-11-13
  • 打赏
  • 举报
回复
string str=" update sc set grade='" + this.textBox3.Text + "' where sno='" + this.textBox1.Text + "' and cno='" + this.textBox2.Text+"' "; 如果碰到sql语句问题,你可以用下面语句,把sql数据输出,再放到数据库中执行,看看是哪里的问题。 Response.Write(str); Response.End(); 以后碰到程序语句错误,你也可以用Response.Write(),Response.End(),分段测试程序,一段段排除。
宝_爸 2014-11-13
  • 打赏
  • 举报
回复
改成下面的,然后设置断点,看看sql的值是什么,很容易找到错误,或者试着在sql server management studio中运行下。 string sql = "update sc set grade='" + this.textBox3.Text + "' where sno=" + this.textBox1.Text + "cno='" + this.textBox2.Text; int Rtn = db.ExecuteNonQuery(sql );
threenewbee 2014-11-12
  • 打赏
  • 举报
回复
sno cno如果是数字,不要加引号,如果是字符串要加引号 cno前面缺少 " and ",注意空格
wind_cloud2011 2014-11-12
  • 打赏
  • 举报
回复
int Rtn = db.ExecuteNonQuery( "update sc set grade='" + this.textBox3.Text + "' where sno='" + this.textBox1.Text + "' and cno='" + this.textBox2.Text+"'");
wind_cloud2011 2014-11-12
  • 打赏
  • 举报
回复
"update sc set grade='" + this.textBox3.Text + "' where sno='" + this.textBox1.Text + "' and cno='" + this.textBox2.Text+"'";

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧