1.这样可以:
command.CommandText = @"Update college Set name='mick' where ID=" + textBox3.Text;2.这样却不行:
command.CommandText = @"Update college Set name=" + textBox1.Text + @"where ID=" + textBox3.Text;
错误信息:
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 System.Data.dll 中。
其他信息: 语法错误 (操作符丢失) 在查询表达式 'mickwhere ID=1' 中。3.这样仍然不行:(where前面加了个空格)
command.CommandText = @"Update college Set name= " + textBox1.Text + @" where ID=" + textBox3.Text;
错误信息:
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 System.Data.dll 中。
其他信息: 至少一个参数没有被指定值。请问应如何处理?
急 多谢!!!!
command.CommandText = @"Update college Set name='mick' where ID=" + textBox3.Text;2.这样却不行:
command.CommandText = @"Update college Set name=" + textBox1.Text + @"where ID=" + textBox3.Text;
错误信息:
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 System.Data.dll 中。
其他信息: 语法错误 (操作符丢失) 在查询表达式 'mickwhere ID=1' 中。3.这样仍然不行:(where前面加了个空格)
command.CommandText = @"Update college Set name= " + textBox1.Text + @" where ID=" + textBox3.Text;
错误信息:
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 System.Data.dll 中。
其他信息: 至少一个参数没有被指定值。请问应如何处理?
急 多谢!!!!
解决方案 »
- 从一个datatable生成新datatable时,其中一列数据从正数变负数
- 求救:项目签合同的难题
- c# 如何显示指定文件夹中所有图片
- 在c#里面有没有划直线的控件
- 求解C# Combox Items集合复制问题
- mysql数据库获得数据,把数据放到DataSet,然后进行数据转换,一个字典数据库类型是double,但是无法转换为c#类型中的double
- 怎么把查询出来的数据库datatable的整个表数据插入到sqlite数据库的表中
- select语句
- 有个入门问题请教!
- 获取一个10:00:00格式的datetime字段
- winform间方法调用的问题,求解答
- winform中文本框能显示图片吗,点击时如何不显示输入光标
command.CommandText = @"Update college Set name=" + textBox1.Text + @"where ID=" + textBox3.Text;
错误信息:
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 System.Data.dll 中。
其他信息: 语法错误 (操作符丢失) 在查询表达式 'mickwhere ID=1' 中。
说的很清楚了, 语法错误 name='" + textBox1.Text + "' where ID=" where前面加空格,text内容用引号
command.CommandText = string.Format("Update college Set name='{0}' where ID={1}",textBox1.Tex,textBox3.Tex)
command.CommandText = @"Update college Set name=" + textBox1.Text + @"where ID=" + textBox3.Text;
在数据库中这个字段是字符类型的,所以要加'
如下:
command.CommandText = @"Update college Set name='" + textBox1.Text + @"' where ID=" + textBox3.Text; 这样估计OK的。
command.CommandText = @"Update college Set name='" + textBox1.Text + "' where ID=" + textBox3.Text+";
如果是文本类型,注意在变量前后都要加上单引号
如果是数字类型,就不必加单引号
这就是为什么你1可以,2,3不行的原因。