首页 > 代码库 > sqlite3 数据操作 修改

sqlite3 数据操作 修改



sqlite3 * db = [Database openDB];
    
    sqlite3_stmt * stmt = nil;
    
    NSString * sqlstring = [NSString stringWithFormat:@"update Student set name = ‘%@‘ where id = %ld" , name , (long)ID];
    
    int result = sqlite3_prepare_v2(db, [sqlstring UTF8String], -1, &stmt, NULL);
    
    if (result == SQLITE_OK) {
        
        if (sqlite3_step(stmt) == SQLITE_DONE) {
            
            sqlite3_finalize(stmt);
            [Database closeDB];
            
            return YES;
        }
    }
    
    
    sqlite3_finalize(stmt);
    
    [Database closeDB];
    return NO;



sqlite3 数据操作 修改