向表添加行 - 主键/自动增量错误(System.Data.SQLite)
我试图将一个新行插入有四个字段的数据库中,第一个是设置为自动递增(整数)的主键,其他三个是字符串。
我插入一个新的语句:
插入制造商值 ('测试1','测试2','01332232321')
但出现以下异常:
“SQLite 错误\r\n表制造商 有 4 列,但有 3 个值 提供”
可以省略,因为数据库会自动为我分配和增加值。
我将如何解决这个问题?这是一个简单的语法错误还是我需要完全重新考虑我的方法?
I'm trying to insert a new row into a database which has four fields, the first is a primary key set as auto incrementing (integer) and the other three are strings.
I insert a new with the following statement:
INSERT INTO Manufacturer VALUES
('Test1','Test2','01332232321')
But I am given the following exception:
"SQLite error\r\ntable Manufacturer
has 4 columns but 3 values were
supplied"
I assumed that the primary key field can be omitted as the database would automatically assign and increment the value for me.
How would I go about fixing this? Is this a simple syntatical error or do I need to rethink my approach completely?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须指定列:
或为主键列传递 NULL 值。
You have to specify columns:
or pass the NULL value for primary key column.
我认为您正在寻找如何在sqllite中自动增量
也如何创建自动增量字段
I think you're looking for how to AUTOINCREMENT in sqllite
also How do I create an AUTOINCREMENT field