update statement in sqlite
sqlite3_stmt *updateStmt = n开发者_运维百科il;
if (updateStmt == nil)
{
const char *sql = " update PPM set amount = ? ";
if (sqlite3_prepare_v2(appDelegate.PPMdatabase, sql, -1,&updateStmt, NULL)!= SQLITE_OK)
{
NSAssert (0,@"Error while creating update statement. '%s'",sqlite3_errmsg(appDelegate.PPMdatabase));
}
}
sqlite3_bind_double (updateStmt,1, Val);
if (SQLITE_DONE != sqlite3_step(updateStmt))
{
NSAssert(0,@"Error while updating.'%s'",sqlite3_errmsg(appDelegate.PPMdatabase));
}
sqlite3_reset(updateStmt);
I get error: error while updating.unkown error
You should be comparing sqlite3_step()
against SQLITE_OK
and then using the extended result codes for finer discrimination. Even the documentation calls this scheme "goofy".
The reason you are getting an "Unknown Error" is probably because you are calling sqlite3_errmsg
when there was no error (that is, step() returned OK).
精彩评论