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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:53:40+00:00 2026-05-17T16:53:40+00:00

/* DATABASE INIT */ ret = sqlite3_open_v2(dbfile, &DB, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); if (SQLITE_OK

  • 0
  /* DATABASE INIT */

ret = sqlite3_open_v2(dbfile, &DB, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);

if (SQLITE_OK != ret) {
    printf("Could not open database.\n");
    exit(1);
}

const char* zSql = "INSERT INTO abc VALUES (?)";
ret = sqlite3_prepare_v2(sites[DB, zSql, strlen(zSql), &s, NULL);

if (SQLITE_OK != ret) {
    printf("Could not compile statement '%s', got %d.\n", zSql, ret);
    exit(1);
}

Well, there you go. What’s wrong? sqlite3_prepare_v2 always fails.

Update:
I tried the suggestions so far, but no cigar.
I created the simplest case I could think of, with a schema:

CREATE TABLE abc(a INTEGER);

And the C code as above, still does not work, gets ‘Could not compile statement’
got return code 26 which apparently means SQLITE_NOTADB. So it seems my database file is not… a database file. Strange, I will have to look into this.

The sqlite CLI accepts the file and can show the schema if I use the “.dump” command.

I changed the database file name from “data.db” to “data.sqlite”. Now I get a return code of 1, SQLITE_ERROR, instead.

Update:
I was accessing the wrong file, AKA user error.
Accepting one of the answers that pointed out a syntax error in my unedited question.

  • 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-17T16:53:41+00:00Added an answer on May 17, 2026 at 4:53 pm

    I think you should try

    const char* zSql = 
        "INSERT INTO abc (moderation_status, phonenumber, email) VALUES(?,?,?)";
    

    assuming moderation_status phonenumber and email are the names of the fields in your table.

    or:

    const char* zSql = "INSERT INTO abc VALUES(?,?,?)";
    

    The ? is the placeholder for where the arguments will be inserted.

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

Sidebar

Related Questions

-(void) readProductsFromDatabase { // Setup the database object sqlite3 *database; // Init the animals
How to retrieve data from sqlite database? Getting return value zero. -(id)init{ if(self==[super init]){
- (UserInfo*)getCurrentUserInfo:(NSString*)userName { UserInfo *userInfo = [[UserInfo alloc]init]; sqlite3 *database; sqlite3_stmt *selectstmt; NSLog(@userName:%@,userName); if(sqlite3_open([databasePath
I have HSQLDB database which i was unable to open. SQL client throws following
sql command BACKUP DATABASE [databasesample] TO DISK = N'D:\kkk\test.bat' WITH INIT , NOUNLOAD ,
I have an init script for my MySQL database but for test purposes I
There is a problem when I init a PostgreSQL database in a FreeBSD jail.
In the following program, I open a BDB environment open a database DB_BTREE/DB_CREATE close
I backed up a database: BACKUP DATABASE MyDatabase TO DISK = 'MyDatabase.bak' WITH INIT
- init { if(![super init]) return nil; //the database is stored in the application

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.