以下は、画像をsqliteデータベースに保存するための私のコードです。私は値を格納するためにそれを使用すると、今私はsqliteデータベースに画像を格納しようとしています。私は何が間違っているのか分からない。私はすでに検索し、私は必要な答えを得ることができません。誰でも彼のコードを教えてください。 画像をsqliteデータベースに保存
sqlite3 *database;
[email protected]"dataTable.sqlite";
NSArray *documentpath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentdir=[documentpath objectAtIndex:0];
dbPath=[documentdir stringByAppendingPathComponent:dbName];
sqlite3_stmt *compiledStmt;
if(sqlite3_open([dbPath UTF8String], &database)==SQLITE_OK){
NSLog(@"Name:%@,Company:%@,URL:%@",model.personName,model.companyName,model.imgurl);
const char *insertSQL="insert into Persons(PersonName,CompanyName,ImgUrl,PersonImage)values(?,?,?,?)";
if(sqlite3_prepare_v2(database,insertSQL, -1, &compiledStmt, NULL)==SQLITE_OK){
sqlite3_bind_text(compiledStmt,1,[model.personName UTF8String],-1,SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStmt,2,[model.companyName UTF8String],-1,SQLITE_TRANSIENT);
sqlite3_bind_text(compiledStmt,3,[model.imgurl UTF8String],-1,SQLITE_TRANSIENT);
NSData *imageData=UIImagePNGRepresentation(imageView.image);
sqlite3_bind_blob(compiledStmt, 4, [imageData bytes], [imageData length], NULL);
NSLog(@"Prepare");
sqlite3_step(compiledStmt);
}sqlite3_finalize(compiledStmt);
}
はUPDATE:すべての人に おかげで..私はこれが他の人に役立つことstore and retrieve image into sqlite database for iphone ..ここから尋ねた別の質問でこの問題をクリア。
イムを貼り付け 後藤の.mファイル.... –
一度に*だけ*ご質問ください。 – Sathya
@Sathya okk ...私の1番目の質問で私を助けることができます..私はそれを編集します.. –