i got a problem with inserting a blob into a sqlite db. I'm workin on ios so it's objective-c.
the plan:
i'm pressing a button, a photo picker opens, i'm choosing a photo, im touching another button, the photo is saved in the db as a blob.
everything is working fine only the inserting not. Im allready inserting int and strings into the db and it works fine, but the blob makes me crazy.
The Code im Using:
i got a class where i got all db-methods in it. its called db. and i got a class where im using the db-object.
DB-Class:
-(void)insertblob:(NSData *)blob stmt:(NSString *)blobStmnt {
const char *sql = [blobStmnt UTF8String];
sqlite3_prepare_v2(database, sql, 1, &statement, NULL);
if (SQLITE_DONE != sqlite3_step(statement)) {
NSLog(@"Error while inserting data. '%s'", sqlite3_errmsg(database));
}
sqlite3_bind_blob(statement, 1, [blob bytes], [blob length], SQLITE_TRANSIENT);
}
Using-Class:
[database openDB:@"Content"]
updateStmt = [NSString stringWithFormat:@"UPDATE Face SET image =%@", image];
[database insertblob:imageData stmt:updateStmt];
[database closeDB];
So What am i missing? I'm getting the error that the inserting allready fails at the "U" from my update statement. but i really don't know what i have to change.
Thanks in advance for your help!
SQLis not efficient and provably should be avoided. Use your local storage to store the image and useSQLto store the reference to that path / image name