Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:23:32+00:00 2026-06-13T01:23:32+00:00

In my application, I have multiple images in an SQLite database since I want

  • 0

In my application, I have multiple images in an SQLite database since I want to change to the next image on button click.

Here is 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];
  }

  }

It’s not working. Please help me to solve it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:23:33+00:00Added an answer on June 13, 2026 at 1:23 am

    From your question I understand that you need to change the image on each button click. If I’m correct then change the changenext method like:

    -(IBAction)changenext
      {
        static int j = 0;
        if (j > 10)
        {
           j = 0;
        }
        [self Readthesqlitefile:j];
        j++;
      }
    

    The above method will change the image on each button click. After displaying the last image it again starts from first image.

    EDIT:

    Also this line seems to be wrong

    const char *chstmt="SELECT * FROM animal where rowid= = %d",sno; .

    There is no == operator in sqlite3 (I’m think so).
    Replace that line by,

    NSString *query    = [NSString stringWithFormat:@"SELECT * FROM animal where rowid = %d",sno];
    const char *chstmt = [query UTF8String];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My application is going to have multiple images.. <mx:Image id=img1 source=@Embed(source='assets/mrute1.jpg') mouseDown=mouseMoveHandler(event);/> <mx:Image id=img2
I have an application that requires processing multiple images in parallel in order to
I have an application with images stored in multiple categories, currently being stored by
In my iPad Application I have multiple views on a screen. What I want
_Hey, I have a question. I want to write application which will have multiple
I have an application wherein I am hosting multiple types of content (images, PowerPoint
I have multiple projects with directory structure like this: /application/ /images/ /js/ /css/ /system/
I am creating an application that will have multiple images on the screen, these
I am working on a WP7.5 application where I have to download multiple images
In my application I want to attach multiple photos to an email in code,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.