Arbol One <[email protected]> wrote:
> rc = sqlite3_open_v2(dbName.c_str(), &db, SQLITE_OPEN_READWRITE |
> SQLITE_OPEN_CREATE, vfs.data());
Just pass NULL for the last parameter. There is very rarely a need to pass
anything else.
> *//2 . ) create a table
> std::string create_table("CREATE TABLE friend (name TEXT, address TEXT, age
> INT)");
> rc = sqlite3_prepare_v2(
> &db, /* Database handle */
Drop the ampersand. Note that, while sqlite3_open_v2 takes sqlite3** (two
stars), sqlite3_prepare_v2 wants sqlite3* (one star).
> creat_table.c_str() , /* SQL statement, UTF-8 encoded */
> ??, /* Maximum length of zSql in bytes. */
You can pass creat_table.length(), or simply pass -1 and have SQLite accept all
characters up to the terminating NUL.
> ??, /* OUT: Statement handle */
Same story as with sqlite3_open_v2 and DB handle. You declare a variable like
"sqlite3_stmt* stmt;", then pass &stmt.
> ?? /* OUT: Pointer to unused portion of zSql */
Just pass NULL. This is used when you have a single string containing multiple
statements.
Note that sqlite3_prepare_v2 only prepares the statement, but doesn't actually
execute it. To run the statement, you would call sqlite3_step. After you are
done, call sqlite3_finalize to free resources associated with the statement;
and sqlite3_close to close your database connection.
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users