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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:42:50+00:00 2026-06-08T07:42:50+00:00

When I type into Sqlite SELECT Count(*) FROM tabl; it returns a number. How

  • 0

When I type into Sqlite

SELECT Count(*) FROM tabl;

it returns a number.

How do I use the C interface to obtain this number after preparing a statement?

  • 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-08T07:42:53+00:00Added an answer on June 8, 2026 at 7:42 am

    Open the database file, prepare the statement, make steps (i.e., if you have more than one row in results you have to fetch them one by one), extract column values, finalize the statement, close the database.

    Something like this:

    sqlite3_stmt* stmt = NULL;
    
    sqlite3* local_db = NULL;
    
    sqlite3_open("filename.sqlite", &local_db);
    
    int retval, idx;
    char sql[2048];
    
    sprintf(sql, "select Something from Somewhere;");
    
    // execute statement
    retval = sqlite3_prepare_v2(local_db, sql, -1, &stmt, 0);
    
    if(retval)
    {
        printf("Selecting data from DB Failed (err_code=%d)\n", retval);
        return;
    }
    
    // iterate rows
    idx = 0;
    
    // for multiple results
    while(1)
    {
        // fetch a row's status
        retval = sqlite3_step(stmt);
    
        if(retval == SQLITE_ROW)
        {
            Something =
                 (int)sqlite3_column_int(stmt, 0);
                 // or other type - sqlite3_column_text etc.
            // ... fetch other columns, if there are any
        }
        else if(retval == SQLITE_DONE)
        {
            break;
        }
        else
        {
            sqlite3_finalize(stmt);
            printf("Some error encountered\n");
            break;
        }
    }
    
    sqlite3_finalize(stmt);
    
    sqlite3_close(local_db);
    

    Use this code, look for all the API calls (open, prepare_v2, step, column, finalize).

    If this is hard, then at first you should become familiar with C itself.

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

Sidebar

Related Questions

When I type this into the Visual Studio 2008 immediate window: ? .9 -
I'm trying to use DbLinq with a SQLite database, but I'm running into a
I'm using the SQlite package to interface with a database from R. However, I'm
What test text do you try and type into your web forms to check
How can I convert a PSID type into a byte array that contains the
jQuery autocomplete plugin shows results that begin with the query you type into a
I have a block of code that serializes a type into a Html tag.
I have the following example of what a user might type into a field
I need to convert values of type T into JsArray . For example, I
How to cast an object (of type Object) into its real type? I need

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.