如何将图像保存到sqlite数据库?

时间:2011-08-05 05:55:50

标签: iphone

我开发了一个应用程序。我在3个视图中查看图像。前2个视图运行良好。但是在第三个视图中图像不保存在数据库中。下面是我的代码,用于更新图像。

-(void)updateStaff:(DataBaseFields*)databasefields
{
if(stfupdateStmt == nil) {
    const char *sql = "update FoodBlogger Set update_date_time = ?, Stf_Mgr_Image = ?, Stf_Mgr_Text = ?, Stf_Srvr_Image = ?, Stf_Chf_Image = ?, Stf_Owr_Image= ? Where insert_date_time = ?";
    if(sqlite3_prepare_v2(database, sql, -1, &stfupdateStmt, NULL) != SQLITE_OK) 
        NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(database));
}

sqlite3_bind_text(stfupdateStmt, 1, [databasefields.update_datetime UTF8String], -1, SQLITE_TRANSIENT);

sqlite3_bind_blob(stfupdateStmt, 2, [databasefields.mgrImage bytes], [databasefields.mgrImage length], SQLITE_TRANSIENT);

sqlite3_bind_blob(stfupdateStmt, 3, [databasefields.srvrImage bytes], [databasefields.srvrImage length], SQLITE_TRANSIENT);

sqlite3_bind_blob(stfupdateStmt, 4, [databasefields.chfImage bytes], [databasefields.chfImage length], SQLITE_TRANSIENT);

sqlite3_bind_blob(stfupdateStmt, 5, [databasefields.owrImage bytes], [databasefields.owrImage length], SQLITE_TRANSIENT);

sqlite3_bind_text(stfupdateStmt, 6, [databasefields.insert_datetime UTF8String], -1, SQLITE_TRANSIENT);

if(SQLITE_DONE != sqlite3_step(stfupdateStmt))
    NSAssert1(0, @"Error while updating. '%s'", sqlite3_errmsg(database));

sqlite3_reset(stfupdateStmt);

}

数据库类型中的图像变量是varchar.Before 2个视图正常工作。但是这个视图不起作用。所以请帮我解决这个问题。

0 个答案:

没有答案