sqlite3 数据操作 添加



 sqlite3 * db = [Database openDB];
    
    sqlite3_stmt * stmt = nil;
    
    NSString * sqlString = [NSString stringWithFormat:@"insert into Student (name , age , gender ) values (‘%@‘ , %ld ,‘%@‘ )",studnt.name , (long)studnt.age ,studnt.gender];
    int result = sqlite3_prepare_v2(db, [sqlString UTF8String], -1, &stmt, nil);
    
    if (result == SQLITE_OK) {
        
           SQLITE_DONE 判断语句执行完成.
        if (sqlite3_step(stmt) == SQLITE_DONE) {
            
            sqlite3_finalize(stmt);
            [Database closeDB];
            return YES;
        }
        NSLog(@"1错误");
        
    }
    NSLog(@"2错误");
    sqlite3_finalize(stmt);
    [Database closeDB];




sqlite3 数据操作 添加

上一篇:sqlite3 数据操作 删除


下一篇:Feedback or feedforward?