我有代码:
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语句会执行呢?
提前致谢。