Newbie89 Posted March 27, 2013 Share Posted March 27, 2013 #include <stdio.h>#include <sqlite3.h>#include <stdlib.h>static char *createsql = "CREATE TABLE Employee(" "ID INTEGER PRIMARY KEY," "Name VARCHAR(10)," "BadgeID VARCHAR(10));";static char *insertsql = "INSERT INTO Employee VALUES(NULL, 'Danny', '12345');";static char *querysql = "SELECT * FROM Employee;";void main(void){int i,j;int rows, cols;sqlite3 *db;char *errMsg = NULL;char **result;/* Open database file */if (sqlite3_open("my_example.db3", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)){ return ;}/* Build Table */ sqlite3_exec(db, createsql, 0, 0, &errMsg);/* Add a new record */ sqlite3_exec(db, insertsql, 0, 0, &errMsg);/* Get the last insert record's ID */ printf("%d\n", sqlite3_last_insert_rowid(db));/* Get all records in database */ sqlite3_get_table(db , querysql, &result , &rows, &cols, &errMsg);/* List all the data */ for (i=0;i<rows;i++){ for (j=0;j<cols;j++) { printf("%s\t", result[i*cols+j]); } printf("\n");} /* Free table */ sqlite3_free_table(result);/* Close database */ sqlite3_close(db);} Above is the code...When I'm compile it,I get the error in the terminal: hong@ubuntu:~/test$ gcc -lsqlite3 -o sqlite_exp sqlite_exp.csqlite_exp.c: In function ‘main’:sqlite_exp.c:18:1: error: too many arguments to function ‘sqlite3_open’/usr/include/sqlite3.h:2579:16: note: declared heresqlite_exp.c:32:1: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘sqlite3_int64’ [-Wformat] Can anyone help me point out the correction?thanks... Link to comment Share on other sites More sharing options...
justsomeguy Posted March 27, 2013 Share Posted March 27, 2013 It says exactly what the problem is: error: too many arguments to function ‘sqlite3_open’ It also looks like you're not escaping quotes correctly in your create query, but it should show a syntax error about that. Maybe it didn't paste correctly. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now