mardi 10 mars 2015

how to show the NSData value in UIImage View while retrieving the database

Added the images as NSData in database successfully. But while i'm retrieving back NSData to UIImage its not working. The following codings that i used for retrieving the database any error please suggest me.enter image description here


Here i used primary key to fetch correct image presented in particular record:



-(void)ShowImagesinImageView{

NSLog(@"Loaded in productlist");
NSLog(@"Primary Key of Expenses ID=%@",primarykeyID);

proID = [[NSMutableArray alloc] init];
NSInteger proeditid = [primarykeyID integerValue];
int len = 0;

NSString *queryStr = [NSString stringWithFormat:@"select image from selection_tbl where expenses_id=?"];
Dataware *dbsql = [[Dataware alloc] initDataware];
sqlite3_stmt *sqlStmt=[dbsql OpenSQL:[queryStr UTF8String]];

Dataware *DB = [[Dataware alloc]initDataware];
sqlite3_stmt *stmt=[DB OpenSQL:[queryStr UTF8String]];
if(sqlStmt != nil)
while(sqlite3_step(sqlStmt) == SQLITE_ROW)
{
len = sqlite3_column_bytes(stmt, 0);
NSData *imagData = [[NSData alloc] initWithBytes: sqlite3_column_blob(stmt, 0) length: len];

sqlite3_bind_int(stmt,1, (int)proeditid);

UIImage *img = [[UIImage alloc] initWithData:imagData];
imageView.image = img;

}
[dbsql CloseSQL];

[tblview reloadData];

}

Aucun commentaire:

Enregistrer un commentaire