执行查询? [英] Execution of query?

查看:95
本文介绍了执行查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SqlCommand cmd = new SqlCommand((UPDATE [Students Records] SET+ textBox2.Text='+ textBox3.Text'WHERE [Reg.No] ='+ textBox1.Text'), con);





这行代码给出错误:

只有分配,调用,增量,递减,等待和新对象表达式可以用作语句。

请回答它?

解决方案

 SqlCommand cmd =  new  SqlCommand(( 更新[学生记录] SET + textBox2.Text   =' + textBox3.Text +  'WHERE [Reg.No] =' + textBox1.Text +  '),con); 



你忘了添加声明末尾的+。



-KR


试试这个



 SqlCommand cmd =  new  SqlCommand(  UPDATE [Students Records] SET + textBox2.Text +   =' + textBox3.Text +  'WHERE [Reg.No] =' + textBox1.Text +   ',con); 


解决方案1很好,但你需要获得一些额外的信息。



请参阅我过去的回答 [ ^ ]。

SqlCommand cmd = new SqlCommand(("UPDATE [Students Records]SET "+ textBox2.Text "='" +textBox3.Text"'WHERE [Reg.No]='"+ textBox1.Text "'"), con);


This line of code gives an error:
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement.
please answer it??

解决方案

SqlCommand cmd = new SqlCommand(("UPDATE [Students Records]SET "+ textBox2.Text "='" +textBox3.Text + "'WHERE [Reg.No]='"+ textBox1.Text +"'"), con);


you forgot to add '+' at the end of the statement.

-KR


Try this

SqlCommand cmd = new SqlCommand("UPDATE [Students Records]SET "+ textBox2.Text +  "='" + textBox3.Text + "'WHERE [Reg.No]='"+ textBox1.Text +  "'", con);


Solution 1 is good, but you need to get some extra information.

Please, see my past answer[^].


这篇关于执行查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆