Hello,
I'm beginner and uses sqlite3.
I'm trying to record informations in a database, but this fails.
I have followed http://www.sqlite.org/c3ref/stmt.html
rc = sqlite3_open(DB_FILENAME, &metadata_db);
rc = sqlite3_exec(metadata_db,
"CREATE TABLE IF NOT EXISTS metadata "
"( filename TEXT, key INT, data BLOB, length INT);",
NULL, NULL,
&error);
rc = sqlite3_prepare_v2(metadata_db,
"INSERT INTO metadata VALUES "
"( ?1, ?2, ?3, ?4 );",
0, &sthl, NULL);
rc = sqlite3_bind_text(sthl, 1, filename, 12, NULL);
rc = sqlite3_bind_int(sthl, 2, key);
rc = sqlite3_bind_blob(sthl, 3, data, data_length, NULL);
rc = sqlite3_bind_int(sthl, 4, data_length);
rc = sqlite3_step(sthl);
rc = sqlite3_finalize(sthl);
rc = sqlite3_close(metadata_db);
I checked all "rc", they are all 0, except sqlite3_step returns 101 (aka
SQLITE_DONE) which is correct according to doc.
The problem is that I obtain a correct database (with 4 fields), but
nothing in it. If I retry this code with an existing database, I still
have the table, but nothign in it.
The only working case is when I add a dummy sqlite3_exec before the
close : this way, the statement is executed (I see data in the db), but
the dummy sqlite3_exec isn't executed (it's a simple INSERT).
This suggests that there is a kind of "flushing" that must be done, and
that it has been done to exec the new sqlite3_exec.
Please let me know what I did wrong.
Have a nice day
--
Olivier FAURAX
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users