Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

get image from database sqlite iphone
#1

-(IBAction)displayimage{

NSString *dbpath = [self getdbpath];

if(sqlite3_open([dbpath UTF8String], &database)==SQLITE_OK)
{

NSString *eid=imageRow.text;


NSString *nsatt=[NSString stringWithFormatAngry"select img1 from
imge where rowid = '%@'",eid];

const char *stmch=[nsatt UTF8String];

if(sqlite3_prepare_v2(database, stmch, -1, &stmnt1, NULL)!
=SQLITE_OK)
{
NSAssert1(0,@"Error in
preparing:'%s'",sqlite3_errmsg(database));
}

if (SQLITE_DONE != sqlite3_step(stmnt1)) {


NSData *data=[[NSData alloc]
initWithBytesConfusedqlite3_column_blob(stmnt1, 0)
lengthConfusedqlite3_column_bytes(stmnt1, 0)];

if (data==nil) {
NSLog(@"No Image Fount");
}
else {

// img.image=[UIImage imageWithData:data];

image *im=[[image alloc]initWithNibNameAngry"image"
bundle:nil];

[self presentModalViewController:im animated:YES];

im.photo.image=[UIImage imageWithData:data];

[im release];

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)