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

  • Home
  • SEARCH
  • 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 6853893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:33:58+00:00 2026-05-27T01:33:58+00:00

I am trying to fetch data from SQLite database(NSArray of strings) and populate the

  • 0

I am trying to fetch data from SQLite database(NSArray of strings) and populate the contents in table view cells. I tried to execute the query in command prompt and it works fine. But in code, it returns an empty array.

NSString *temp = [[NSString alloc]initWithFormat:@"select img.image from images img,illness i,illness_images ii where img.img_id=ii.img_id and i.i_id=ii.i_id and i.i_id = '%d'",illid];
        const char *sqlStatement = [temp UTF8String];
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) 
        {
            // Loop through the results and add them to the array
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) 
            {
                // Read the data from the result row
                NSString *imgname = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];

                [imglist addObject:imgname];
                sqlite3_finalize(compiledStatement);

            }
        }
        else{
            NSAssert1(0,@"Error retrieving image names '%s'",sqlite3_errmsg(database));
        }

I tried to debug and when it reaches while(sqlite3_step(compiledStatement) == SQLITE_ROW) , it does not enter the loop.
Not sure whats the mistake I am doing.

Thanks!

  • 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-05-27T01:33:59+00:00Added an answer on May 27, 2026 at 1:33 am

    Try NSLog after assigning the string query to temp variable.
    and check if the variable illid is giving you the correct value and run that query on the database directly.

    NSString *temp = [NSString stringWithFormat:@"select img.image from images img,illness i,illness_images ii where img.img_id=ii.img_id and i.i_id=ii.i_id and i.i_id = %d",illid];
    

    and you better release the allocated object or use class methods setting value, for memory management.

    HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I'm trying to fetch data from the sqlite database table the NSArray has
in my app i am trying to fetch some data from database and i
I am trying to fetch data from my database and when I display it
I am trying to fetch data from the following database data: And display the
I'm trying to fetch some data from a database. I want to select an
I'm trying to fetch data from a div (based on his id), using PHP's
I'm trying to fetch the most popular tags from all videos in my database
I am trying to fetch data from DB and loading the DB with the
I'm using an Oracle DB and I'm trying to fetch data from its tables
I'm was trying a tutorial to get data to android from a MySQL database

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.