0
我似乎误解了该基本语法,为什么这个样品的工作原理:SQLITE基本语法
sqlite3_prepare_v2(db, "insert into test values('boo','boo',0);", strlen(querystring)+1 , &stmt, NULL);
if ((rc = sqlite3_step(stmt)) != SQLITE_DONE)
fprintf(stderr, "Error: sqlite3_step() %d. Error Message %s;\n",rc,sqlite3_errmsg(db));
但当我尝试此查询: “插入测试(strtest)VALUES(‘嘘’);”
我收到一个错误: 错误:sqlite3_step()19.错误消息约束失败;
我错过了什么?
table test is:“create table test(blobtest BLOB(4)NOT NULL,strtest VARCHAR NOT NULL,inttest INTEGER NOT NULL);”
感谢, Doori酒吧
非常感谢! (我想你实际上意味着strtest被设置为'boo',但blobtest和inttest没有NULL或缺省值,对吗? – 2010-06-14 15:41:49
@Doori Bar - Nope,'blobtest'是你的模式中声明的第一列,所以除非你指定明确的列顺序,例如:'insert into test(inttest,strtest,blobtest)values(...)' – Matt 2010-06-14 15:43:56
但是我做了什么? “insert into test(strtest)values('boo');” – 2010-06-14 15:50:21