我正在使用 iPhone 6.1 模拟器,它可以工作。但是,当我使用我的 iPhone [iOS 6.1] 时,我收到一个错误“更新时出错。不是错误”。帮助!!!!
NSString *filePath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"myDatabase.sqlite"];
NSString* str2 = SeqNo1.text;
sqlite3 *database;
sqlite3_stmt *updateStmt=NULL;
if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK)
{
NSString* sql= [NSString stringWithFormat:@"UPDATE MyTable Set MyField2 = \"%@\" WHERE MyField1 = \"%@\"", @"Y", str2];
if(sqlite3_prepare(db, [sql cStringUsingEncoding:NSASCIIStringEncoding], -1, &updateStmt, NULL) != SQLITE_OK)
NSLog(@"Error while creating update statement. %s", sqlite3_errmsg(database));
}
if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK)
{
int step = sqlite3_step(updateStmt);
if(step != SQLITE_DONE)
NSLog(@"Error while updating. %s", sqlite3_errmsg(database)); // THIS WHERE THE ERROR IS OCCURRING
sqlite3_finalize(updateStmt);
sqlite3_close(database);
}
else{
NSLog(@"Error while Opening Databse. %s", sqlite3_errmsg(database));
}