cmd.CommandText = "update student set shuxue="'+textBox3.Text'"where xuehao in(select Id from chengji where xuehao like'"+"%"+textBox1.Text+"%"+"')";
解决方案 »
- SelectSingleNode()和SelectNodes()的区别是什么啊
- 想学习C#
- IndexOutOfRangeException
- 请问如何在窗体应用程序中写一个方法不影响窗体的运行?
- 将Combox显示的值设置到文本框上 如何做 我写的不行 高手指点 谢谢
- [攒分贴]每日小知识
- System.Net.Sockets.SocketException: 在 getsockopt 或 setsockopt
- 求一数据操作的控件!
- 各位朋友帮忙呀!??
- C# 两个毫无关系的网站之间的控件怎么传值
- richTextBox 批量读取 高亮格式的文本
- 客户端和服务端Socket传输数据问题.[倾家荡产求帮助]带图!!!
cmd.CommandText = "update student set shuxue='"+textBox3.Text+"' where xuehao in(select Id from chengji where xuehao like '%"+textBox1.Text+"%')";
//这样就对了、建议你用参数化的方法、避免字符串写错、如下:
cmd.CommandText = "update student set shuxue=@aa where xuehao in(select xuehao from chengji where xuehao like @bb)";
cmd.Parameters.AddWithValue("@aa",textBox3.Text );
cmd.Parameters.AddWithValue("@bb","%"+textBox1.Text+"%");
如TextBox.Text的值如果输入abc',那么就会有错撒....
不然引号搞晕你啊
sql = string.Format(sql , [0], [1]);
string sql = string.Format("UPDATE {0} SET {1}={2} WHERE xuehao in(select Id from chengji where xuehao like'{3}'",
"student",
"shuxue",
textBox3.Text,
textBox1.Text
);