0
我有一個blob sql數據類型的問題,問題是我無法將NSData插入數據庫,編譯器顯示沒有錯誤,但數據庫文件大小在數據插入後沒有改變,我已經嘗試了所有的東西,這是我寫的最後一個功能,但它似乎工作neider,請幫助,提前致謝!無法在SQLite數據庫中插入blob
sqlite3 *database;
if (sqlite3_open([databasePath UTF8String], &database)== SQLITE_OK)
{
NSString *statement = [[NSString alloc]initWithFormat:@"insert into %@(date,name,type,urlpath) values('%@','%@','0','%@')",mainPath,
currentTime,
(*incomingObject).fileName,
filterURL];
NSLog(@"\n--==%@ %@==--",(*incomingObject).fileName,(*incomingObject).urlAdress);
const char *sqlStatement = [statement UTF8String];
[statement release];
sqlite3_stmt *compiledStatement;
sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL);
sqlite3_step(compiledStatement);
sqlite3_reset(compiledStatement);
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
break;
iv've也是如此。它不起作用 – Florik
sqlite3_bind_blob(compiledStatement,5,[(* incomingObject).file bytes],[(* incomingObject).file length],NULL); – Florik
你可以在第一篇文章中顯示該部分的代碼嗎?它是否在該請求中插入其他數據?屬性中的哪一個是blob數據?你也應該傳遞_bytes_而不是_NSData_本身。例如像這樣:'sqlite3_bind_blob(語句,索引,[imageData bytes],[imageData length],SQLITE_STATIC);'Where其中_imageData_是NSData對象。 –