我无法更新我的数据库:我连接到它然后我使用此功能但它必须执行但没有更新:
- (BOOL) updatePoint:(NSString *) word {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"master.sqlite"];
sqlite3_stmt *statement;
if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
int newPoint = point + 1;
NSString *sql = [NSString stringWithFormat:@"UPDATE %@ SET Point='%d' WHERE Parola=?",
dictionaries1[[[word substringWithRange:NSMakeRange(0,1)] intValue]-1],newPoint];
if(sqlite3_prepare_v2(database, [sql UTF8String], -1, &statement, NULL)==SQLITE_OK)
sqlite3_bind_text(statement,1,[word UTF8String] ,-1, SQLITE_TRANSIENT);
sqlite3_step(statement);
sqlite3_finalize(statement);
//sqlite3_reset(statement);
sqlite3_close(database);
return YES;
} else
return NO;
}
怎么了?
答案 0 :(得分:0)
你可以看一下,上面的更新代码似乎很好,但可能出现的唯一问题可能是由于数据库被覆盖或者可能不在指定位置。 Problem with inserting data into a table
您可以使用更新语句替换插入代码