如何在 sqlite 中更新图像
我有一个来自 imagePickerView 的图像,我想将它以 blob 格式保存在我的 sql 中,我的 sorce 代码怎么能听到
NSString *item = str_Name;
sqlite3_stmt *statement;
NSString *databasePath = [[NSBundle mainBundle] pathForResource:@"SLAMEBOOK" ofType:@"sql"];
if(sqlite3_open([databasePath UTF8String], &SLAMEBOOK) == SQLITE_OK)
{
NSString *insertSQL = [NSString stringWithFormat: @"UPDATE SlammyDetail SET Name= \"%@\", BDate=\"%@\" WHERE Name = \"%@\"", txt_Name.text ,lbl_date.text, item];
const char *insert_stmt = [insertSQL UTF8String];
sqlite3_prepare_v2(SLAMEBOOK, insert_stmt, -1, &statement, NULL);
if (sqlite3_step(statement) == SQLITE_DONE)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success"
message:@"REMINDER Updated"
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Failed to add Task"
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
sqlite3_finalize(statement);
sqlite3_close(SLAMEBOOK);
}
[txt_Name resignFirstResponder];
[[UIApplication sharedApplication] cancelAllLocalNotifications];