我有代码:
if (sqlite3_open([dbPath UTF8String], &db) == SQLITE_OK)
{
const char *sql_stmt = "create table contacts (id integer primary key autoincrement, name text, address text, phone text);";
if (sqlite3_exec(db, sql_stmt, NULL, NULL, NULL) == SQLITE_OK)
{
av = [[UIAlertView alloc] initWithTitle:@"Success!!!" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
}
else
{
av = [[UIAlertView alloc] initWithTitle:@"Error3" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
}
} else {
av = [[UIAlertView alloc] initWithTitle:@"Error2" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
}
我到达 sqlite3_exec 但它返回退出代码 26:打开的文件不是数据库文件。如果是这种情况,为什么 if 语句会执行呢?
提前致谢。