MySQL插入值错误 [英] MySQL insert value error
问题描述
MySQL服务器向visual basic IDE返回一个错误错误:
未处理MySqlExeception:列数与第1行的值计数不匹配。
在查询期间省略了自动递增,可为空的列时,仍会出现此错误。 div class =h2_lin>解决方案
您的查询可能具有以下形式:
INSERT INTO myTable VALUES ( Joe, Bigman Smith)试图在此基础上分配值列号:如果您的自动编号字段在序列的早期,将为其分配给定值之一 - 您将获得等错误。
而不是这样做,请始终为您提供其值的字段命名:
INSERT INTO myTable(FirstName,NickNAme,FamilyName) VALUES ( Joe, Bigman, 史密斯 )这样,数据库就确切地知道你要向哪个列插入一个值,并且可以使用默认值或者它自己的余数。此外,无论如何列出列是个好主意,因为如果以后更改表定义,它会防止数据损坏!
MySQL server returns an an Error an Error to the visual basic IDE :
MySqlExeception was unhandled : Column count does''t match value count at row 1.
This error still occured when a Auto incrementing , nullable column was ommited during the query.
The chances are that your query was of the form:
INSERT INTO myTable VALUES("Joe", "Bigman" "Smith")which tries to allocate values on the basis of column numbers: if your auto number field is early in the sequence, one of the given values will be assigned to it - and you will get an error.
Instead of doing that, always name the fields whose values you are supplying:
INSERT INTO myTable (FirstName, NickNAme, FamilyName) VALUES ("Joe", "Bigman", "Smith")That way, the database knows exactly which column you are trying to insert a value to, and can use defaults or it''s own numbers for the remainder. Plus it''s a good idea to list the columns anyway, as it prevents data corruption if the table definition is changed at a later date!
这篇关于MySQL插入值错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!