不指定栏名称时,用下述写法:string sqlInsert = "insert into tableName values (3,'办公网','计算机教程','讲课老师',0)";可以成功插入数据。
指定栏名称时,用下述写法:string sqlInsert = "insert into tableName(order,netsname,class,teacher,status) values (4,'办公网','计算机教程','讲课老师',0)";其中,order是主键,设为不允许空,自动递增。 提示语法错误。不知原因何在,我用win7 64位系统,MySQL版本为5.5,VS2010采用C#写的窗体程序。
指定栏名称时,用下述写法:string sqlInsert = "insert into tableName(order,netsname,class,teacher,status) values (4,'办公网','计算机教程','讲课老师',0)";其中,order是主键,设为不允许空,自动递增。 提示语法错误。不知原因何在,我用win7 64位系统,MySQL版本为5.5,VS2010采用C#写的窗体程序。
改成这样string sqlInsert = "insert into tableName(netsname,class,teacher,status) values ('办公网','计算机教程','讲课老师',0)";
或者
string sqlInsert = "insert into tableName values ('办公网','计算机教程','讲课老师',0)";
采用string sqlInsert = "insert into tableName(netsname,class,teacher,status) values ('办公网','计算机教程','讲课老师',0)"时,提示
you have an error in your SQL syntax;check the manual that corresponds to your MySQL server version for right syntax to use near 'class,teacher,status) values 乱码 at line 1.采用string sqlInsert = "insert into tableName values ('办公网','计算机教程……时,提示
Column count doesn't match value count at row 1
MySQL不是有两种插入方法吗?
INSERT INTO tablename SET column_name1 = value1, column_name2 = value2,…;
设置了主键递增为啥会报这个错
order都是主键,自动增加了,你还要显示插入干什么呢
自增长是数据库自动控制的,你不能强制为自增长的字段赋值
insert into tableName(netsname,`class`,teacher,status) values ('办公网','计算机教程','讲课老师',0)
关键字要用``符号包起来