I am worse than a newbie at C, but...

On 4/7/08, dark0s dark0s <[EMAIL PROTECTED]> wrote:
> Hi all, after writing my program, I typed:
>
>  bash-3.1# gcc -lsqlite3 CreaDB.c -o creadb
>  CreaDB.c: In function 'main':
>  CreaDB.c:35: error: too few arguments to function 'sqlite3_bind_text'
>  CreaDB.c:36: error: too few arguments to function 'sqlite3_bind_text'
>  CreaDB.c:37: error: too few arguments to function 'sqlite3_bind_text'
>
>  But I don't see the problem, my program is:
>
>  int main(int argc, char** argv[]) {
>
>   int rc, i;
>   sqlite3* db;
>   sqlite3_stmt* stmt;
>   char* sql;
>   const char* tail;
>
>   rc = sqlite3_open("prova.db", &db);
>   if (rc) {
>     fprintf(stderr, "E' impossibile aprire il file %s\n", sqlite3_errmsg(db));
>     sqlite3_close(db);
>     exit(1);
>   }
>
>   sql = "create table modulo(id);";
>
>   rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, &tail);
>   if (rc != SQLITE_OK) {
>     fprintf(stderr, "Errore SQL: %s\n", sqlite3_errmsg(db));
>   }
>
>   rc = sqlite3_step(stmt);
>   sqlite3_reset(stmt);
>
>   sql = "insert into modulo(id, nome, classe, istanza) values(?,?,?,?)";
>   sqlite3_prepare(db, sql, strlen(sql), &stmt, &tail);
>
>   sqlite3_bind_int(stmt, 1, 1);
>   sqlite3_bind_text(stmt, 2, "nome1");
>   sqlite3_bind_text(stmt, 3, "classe1");
>   sqlite3_bind_text(stmt, 4, "istanza1");

aren't you binding 4 values to the SQL statement, but providing only 3?


>   sqlite3_step(stmt);
>
>   while (rc == SQLITE_ROW) {
>     for (i = 0; i < sqlite3_column_count(stmt); i++)
>       fprintf(stderr, "'%s' ", sqlite3_column_text(stmt, i));
>     fprintf(stderr, "\n");
>     rc = sqlite3_step(stmt);
>   }
>
>   sqlite3_finalize(stmt);
>   sqlite3_close(db);
>
>   return 0;
>
>  }
>
>  Thank you very much in advance for answers,
>  savio
>
>
>
>  ---------------------------------
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to