In my application i having multiple image in sq lite database,Since i want to change to the next image on button click,Here my code,
-(void)Readthesqlitefile:(NSInteger *)sno
{
sqlite3 *database;//database object
NSString *docpath=[self doccumentspath];//get sqlite path
const char *ch=[docpath UTF8String];//string to constant char UTF8string main part to connect DB
if (sqlite3_open(ch, &database)==SQLITE_OK) {
const char *chstmt="SELECT * FROM animal where rowid= = %d",sno;
sqlite3_stmt *sqlstmt;//to execute the above statement
if (sqlite3_prepare_v2(database, chstmt, -1, &sqlstmt, NULL)==SQLITE_OK)
{
while (sqlite3_step(sqlstmt)==SQLITE_ROW)
{
const char *Bname=(char *)sqlite3_column_text(sqlstmt, 0);
//converting const char to nsstring
NSString *Bndname=[NSString stringWithFormat:@"%s",Bname];
NSLog(@"Brand Names=%@",Bndname);
lb1.text=[NSString stringWithFormat:Bndname];
NSUInteger legnt=sqlite3_column_bytes(sqlstmt, 1);
if (legnt>0) {
NSData *dt=[NSData dataWithBytes:sqlite3_column_blob(sqlstmt, 1) length:legnt];
clsimg=[UIImage imageWithData:dt];//converting data to image
imager.image=clsimg;
}
else {
clsimg=nil;
}
}
}
sqlite3_finalize(sqlstmt);
}
sqlite3_close(database);
}
Button click function
-(IBAction)changenext
{
int j;
for (j=1; j<10; j++)
{
[self Readthesqlitefile:j];
}
}
its is not working pls help me to solve it out?