我的代码是:
const char *sqlInsertString;
sqlite3_stmt *addStatement;
sqlInsertString=sqlite3_mprintf("insert into AnimalTable(name,propertyID,animalID,breed,dateofbirth,sex,notes,imageData) values" "('%s','%s','%s','%s','%s','%s','%s','%d')",nameString,propertyString,animalidString,breedString,dateofbirth,sexString,notesString,imageData);
if (sqlite3_open([sqlFile UTF8String],&database)==SQLITE_OK) {
sqlite3_prepare_v2(database, sqlInsertString, -1, &addStatement, NULL);
if (sqlite3_step(addStatement)==SQLITE_DONE) {
sqlite3_bind_blob(addStatement, 1, [imageData bytes], [imageData length], NULL);
sqlite3_finalize(addStatement);
NSLog(@"Data saved");
}
else
NSLog(@"Some Error occurred");
}
sqlite3_close(database);
我想我做错了什么,无法弄清楚。每当我将数据添加到 sqlite 时,它都会显示一些错误消息。并且还得到异常 NSInternalInconsistencyException no such table:AnimalTable。但是 AnimalTable 存在,当我在 sqlmanager 中执行查询时它运行正常。