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 6359559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:32:03+00:00 2026-05-24T23:32:03+00:00

I am reading the sqlite but unable to get data instead it showing nil

  • 0

I am reading the sqlite but unable to get data instead it showing nil values. please refer the given code….

-(void)getDatabasePath:(NSString *)dBPath sqlCatagoryId:(NSString *)catId {
     if(sqlite3_open([dBPath UTF8String], &_database) == SQLITE_OK) {
         NSLog(@"database path %@", dBPath);
 NSString *sqlStatement = [NSString stringWithFormat:@"SELECT * FROM SubCategories where CAT_ID = '%@'",catId];

NSString *aCategoryId, *aSubCategoryId, *aSubCategoryName, *aSubCategoryDescription;
 sqlite3_stmt *statement;
     if (sqlite3_prepare_v2(_database, [sqlStatement UTF8String], -1, &statement, nil) 
 == SQLITE_OK) {
         while (sqlite3_step(statement) == SQLITE_ROW) {

             char * str1 = (char *)sqlite3_column_text(compiledStatement, 1);
             if (str1) {
                 aCategoryId = [NSString stringWithUTF8String:str1];
             }
             else {
                 aCategoryId = @"";
             }
             char * str2 = (char *)sqlite3_column_text(compiledStatement, 2);
             if (str1) {
                 aSubCategoryId = [NSString stringWithUTF8String:str2];
             }
             else {
                 aSubCategoryId = @"";
             }
             char * str3 = (char *)sqlite3_column_text(compiledStatement, 3);
             if (str1) {
                 aSubCategoryName = [NSString stringWithUTF8String:str3];
             }
             else {
                 aSubCategoryName = @"";
             }
             char * str4 = (char *)sqlite3_column_text(compiledStatement, 4);
             if (str1) {
                 aSubCategoryDescription = [NSString stringWithUTF8String:str4];
             }
             else {
                 aSubCategoryDescription = @"";
             }

             NSData *aSubCategoryImage;
             NSUInteger blobLength = sqlite3_column_bytes(compiledStatement, 5);
             if(blobLength > 0){
                 aSubCategoryImage = [NSData dataWithBytes:sqlite3_column_blob(compiledStatement, 5) length:blobLength];
             }
             else {
                 aSubCategoryImage = nil;
             }

             SubCategoryModel *subCategoryModel = [[SubCategoryModel alloc] initWithCategoryId:aCategoryId subCategoryId:aSubCategoryId subCategoryName:aSubCategoryName subCategoryDescription:aSubCategoryDescription subCategoryImage:aSubCategoryImage];// database:database
             //Add the details object to the Array   
             [subCategorryArray addObject:subCategoryModel];
              [subCategoryModel release];
        }
 sqlite3_finalize(statement);
     }
    }
     [self.aTableView reloadData];
 }

please point out where I am going wrong or why I am not able to get data from sqlite. 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-24T23:32:04+00:00Added an answer on May 24, 2026 at 11:32 pm

    I was doing wrong in sqlite3_stmt *statement; and sqlite3_stmt * compiledStatement;
    that I mixed the both sqlite3_stmt

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

Sidebar

Related Questions

I have a SQLite database that is created by reading some data in PDF
I've done a bit of reading related to the concurrency issues with sqlite, but
I'm reading data from a sqlite database however in my detailed view one of
I am reading a sqlite file in which datetime column data are saved as
I am reading data from a table and updating into other table in SQLite.
I have a problem reading out multiple rows that get returned from an SQLite
Possible Duplicate: Reading and writing images to an SQLite DB for iPhone use How
Reading this question I found this as (note the quotation marks) code to solve
Reading source code of sample projects, such as Beast and Bort, are recommended as
I've been reading through this tutorial for using a SQLite database within an iPhone

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.