LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   can not create sqlite table with C API (https://www.linuxquestions.org/questions/programming-9/can-not-create-sqlite-table-with-c-api-907079/)

golden_boy615 10-08-2011 05:36 AM

can not create sqlite table with C API
 
hello
I am new in sqlite and this is my C code :


Code:

#include <stdio.h>
#include <sqlite3.h>
#include <string.h>


int main()
{
 sqlite3 *db;
 sqlite3_stmt *stmt;
 char *sqlitequery="create table ee (row INTEGER PRIMARY KEY,a INTEGER);";
 int rc = 0;

  rc = sqlite3_open("eh.db", &db);
  if( rc )
  {
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
  }
  else
  {
    rc = sqlite3_prepare_v2(db, sqlitequery, strlen(sqlitequery), &stmt, 0);
    printf("return value %d:",rc);
    if( rc )
    {
      fprintf(stderr, "SQL error: %d : %s\n", rc, sqlite3_errmsg(db));
    }
 }
 return 0;
}

this code makes database file for me but it does not create its table named "ee" into it.
what is wrong with it?

golden_boy615 10-08-2011 05:38 AM

sorry I saved this post two times...

crabboy 10-08-2011 10:33 AM

Please follow discussion here:
http://www.linuxquestions.org/questi...-c-api-907078/


All times are GMT -5. The time now is 05:49 AM.