我正在更新 SQLite 数据库。当我更新单个数据时(意味着它正在更新的数据库字段的 AcountName )。但是当我一起更新多个字段时(如 AcountName、UserName、Password、Url,请注意与 AcountName 的任何组合,然后应用程序在sql = [NSString stringWithFormat:@"update UserInfo1 set AcountName=?, UserName=?, Password 处崩溃=?, Url=?, Note=? where AcountName='%@'",strAcountName]; )
-(void)updateData:(NSString *)AcName :(NSString *)UsrName :(NSString *)Pswd :(NSString *)url :(NSString *)Note
{
sqlite3_stmt *updateStatement = nil;
NSString *sql;
int returnvalue;
sql = [NSString stringWithFormat:@"update UserInfo1 set AcountName=?, UserName=?, Password=?, Url=?, Note=? where AcountName='%@'",strAcountName];
returnvalue = sqlite3_prepare_v2(database, [sql UTF8String], -1, &updateStatement, NULL);
if (returnvalue == 1)
{
NSAssert1 (0,@"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
}
sqlite3_bind_text(updateStatement, 1,[AcName UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStatement, 2,[UsrName UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStatement, 3,[Pswd UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStatement, 4,[url UTF8String],-1, SQLITE_TRANSIENT);
sqlite3_bind_text(updateStatement, 5,[Note UTF8String], -1, SQLITE_TRANSIENT);
if(sqlite3_step(updateStatement) != SQLITE_DONE )
{
bulDataExist = YES;
[strAcountName retain];
}
else
{
sqlite3_reset(updateStatement);
bulDataExist = NO;
}
sqlite3_finalize(updateStatement);
}
Sent at 6:11 PM on Tuesday
请纠正我。
谢谢