在我的项目中,我创建了一个新的数据库表单puglin firefox:
-(void)viewDidLoad{
sqlite3 *db;
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSString *dbPath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"registros.sqlite"];
BOOL success = [fileMgr fileExistsAtPath:dbPath];
int resultado = sqlite3_open([dbPath UTF8String], &db);
if(success == true){
NSLog(@"The database Reconized File Exist");
}
if(resultado == SQLITE_OK){
NSLog(@"The sql is open");
}
char *sql = "INSERT INTO campos (campo1,campo2,campo3) VALUES (?,?,?)";
sqlite3_stmt *stmt;
int resultado2 = sqlite3_prepare_v2(db, sql, -1, &stmt, nil);
if(resultado2 == SQLITE_OK){
NSLog(@"The prepare is execute");
}
sqlite3_bind_text(stmt, 1, [@"Campo_01" UTF8String], -1, nil);
sqlite3_bind_text(stmt, 2, [@"Campo_02" UTF8String], -1, nil);
sqlite3_bind_text(stmt, 3, [@"Campo_03" UTF8String], -1, nil);
resultado2 = sqlite3_step(stmt);
if(resultado2 == SQLITE_DONE){
NSLog(@"Sql Done");
}
sqlite3_finalize(stmt);
}
控制台上的四个日志显示给我,但在我的数据库中,没有任何新值,字段正常,我的数据库名称也可以,所以为什么插入不是工作?