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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:46:50+00:00 2026-06-04T05:46:50+00:00

Presently I am using the following code, but how do I retrieve the count

  • 0

Presently I am using the following code, but how do I retrieve the count after the statement is executed to see whether or not the table contains data?

NSString *sql2 = @"SELECT COUNT( * ) FROM myTable";
sqlite3_stmt *stmt2 = [Cn OpenSQL:[sql2 UTF8String]];

if (stmt2 != nil) 
{
    if(sqlite3_step(stmt2)){
    NSLog(@"success")
    }
    else NSLog(@"err2: %@",sql2);
}
  • 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-04T05:46:52+00:00Added an answer on June 4, 2026 at 5:46 am
    NSString *sql2 = SELECT COUNT(*) FROM `myTable`;
    

    If the result is 0 that means table is empty.

    if (sqlite3_open([self.dataBasePath UTF8String], &articlesDB) == SQLITE_OK)
        {
            const char* sqlStatement = "SELECT COUNT(*) FROM MYTABLE";
            sqlite3_stmt *statement;
    
            if( sqlite3_prepare_v2(articlesDB, sqlStatement, -1, &statement, NULL) == SQLITE_OK )
            {
                //Loop through all the returned rows (should be just one)
                while( sqlite3_step(statement) == SQLITE_ROW )
                {
                    NSInteger count = sqlite3_column_int(statement, 0);
                    NSLog(@"Rowcount is %d",count);
                }
            }
            else
            {
                NSLog( @"Failed from sqlite3_prepare_v2. Error is:  %s", sqlite3_errmsg(articlesDB) );
            }
    
            // Finalize and close database.
            sqlite3_finalize(statement);
            sqlite3_close(articlesDB);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using the following code to present a modal View but still my
From VB.net we can execute VBScript code by using following line: System.Diagnostics.Process.start(AbsolutePathofVBScriptfile) But how
I'm trying to present a UIImagePickerController from a UITableViewController subclass using the following code:
im using the following code to share content on facebook- <a href=https://www.facebook.com/dialog/feed?app_id=325675344144789&link=<?=$station_info->link?>& picture=<?=$station_info->img_url?>& name=<?=$station_info->title?>&
i am using following code to show video library -(IBAction)showVideoLibrary { UIImagePickerController *videoPicker =
Im using the following code to present a file for download. The file saves
using the following code in the parent ViewController, I want to present a second
I am loading a dll in python using following code: if os.path.exists(dll_path): my_dll =
I tried the following code on gcc 4.4.5. If the member 'data' is not
I am using following code to choose image from camera role picker= [[UIImagePickerController alloc]

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.