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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:46:34+00:00 2026-05-23T10:46:34+00:00

I’m starting from the bottom-up to learn iPad development after 15 years with Cold

  • 0

I’m starting from the bottom-up to learn iPad development after 15 years with Cold Fusion. I’m getting comfortable with Ansi C and xCode, but am stumped taking the next step with SQLite.

I’ve built a database (Airports.sqlite) with razorSQL and installed it in the same directory as main.c where I’ve also installed the amalgamated sqlite3.h and sqlite3.h files.

Everything compiles OK, but I get the following message when I Run…

Error in select statement select Length from Runways order by Length desc limit 5 [no such table: Runways].

The database definitely has the Runways table in it. Can someone set me straight? Here’s the code:


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
#include "weightbalance.h"

sqlite3* db;
int first_row;

int select_callback(void *p_data, int num_fields, char **p_fields, char **p_col_names) {

    int i;
    int *p_rn = (int*)p_data;

    if (first_row) {
        first_row = 0;

        for(i=0; i < num_fields; i++) {
            printf("%20s", p_col_names[i]);
        }
        printf("\n");
        for(i=0; i< num_fields*20; i++) {
            printf("=");
        }
        printf("\n");
    }

    (*p_rn)++;

    for(i=0; i < num_fields; i++) {
        printf("%20s", p_fields[i]);
    }

    printf("\n");
    return 0;
}


void select_stmt(const char* stmt) {
    char *errmsg;
    int   ret;
    int   nrecs = 0;

    first_row = 1;

    ret = sqlite3_exec(db, stmt, select_callback, &nrecs, &errmsg);

    if(ret!=SQLITE_OK) {
        printf("Error in select statement %s [%s].\n", stmt, errmsg);
    }
    else {
        printf("\n   %d records returned.\n", nrecs);
    }
}

void sql_stmt(const char* stmt) {
    char *errmsg;
    int   ret;

    ret = sqlite3_exec(db, stmt, 0, 0, &errmsg);

    if(ret != SQLITE_OK) {
        printf("Error in statement: %s [%s].\n", stmt, errmsg);
    }
}

int main() {
    sqlite3_open("Airports.sqlite", &db);

    if(db == 0) {
        printf("Could not open database.");
        return 1;
    }

    printf("\nSelecting Airports with the longest runways.\n\n");
    select_stmt("select Length from Runways order by Length desc limit 5");

    sqlite3_close(db);
    return 0;
}
  • 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-23T10:46:35+00:00Added an answer on May 23, 2026 at 10:46 am

    Most likely, the file “Airports.sqlite” opened in main() is not the one you think it is. Without path information, sqlite3_open() will just open the file in the current working directory.

    As a debug step, add “printf(getwd(NULL))” just before your sqlite3_open() statement. Then you’ll know whether you’re opening your existing database or just creating a new, empty one that is missing your table.

    Also, since you’re using Xcode, you can just pass the path to your database as a command-line parameter (argv). In Xcode 4, choose Product->Edit Scheme. In the “run” section, add the path to “Arguments Pass On Launch”. Then you can just pass argv[1] to your sqlite3_open().

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.