更新SQLite数据库无法正常工作

时间:2013-04-17 11:04:49

标签: ios xcode sqlite

我正在尝试使用XCode 4.3.2更新SQLite数据库中的Userdetail表。我正在使用的代码如下:

-(IBAction)saveUserProfile
{
    sqlite3_stmt *statement;
    const char *dbpath = [mDatabasePath UTF8String];

    if (sqlite3_open(dbpath, &mDiary) == SQLITE_OK)
    {
        NSString *updateSQL = [NSString stringWithFormat: 
                               @"UPDATE USERDETAIL SET mUname = \"%@\", mGender = '%@', mEmail = \"%@\", mAddress = \"%@\", mLatitude = \"%@\", mLongitude = \"%@\" WHERE mUserName = \"%@\" ", mUname.text, mGender.text, mEmail.text, mAddress.text, mLatitude.text,mLongitude.text, mUserName];
        const char *update_stmt = [updateSQL UTF8String];
        sqlite3_prepare_v2(mDiary, update_stmt, 
                           -1, &statement, NULL);
        if (sqlite3_step(statement) != SQLITE_DONE){

            mStatus.text = @"Failed to update user profile";
        }

        sqlite3_finalize(statement);
        sqlite3_close(mDiary);
    }
}

该表未进行更新。问题是什么?

0 个答案:

没有答案