I have a problem with sqlite3_open_v2 function. OS is Windows, developing in Qt Creator.
sqlite3_open("database.db", &db); // works fine
but
sqlite3_open_v2("database.db", &db, SQLITE_OPEN_READWRITE, ""); // don't work
I'm quite sure it's not utf-8 codding problem, cause first function works fine and i tried to change codding in project properties. Maybe problem is with filepath in first arg. Absolute paths didn't work too.
Anyone had any idea and exmple of using this function?
Thanks for answers.
Problem was with last parameter. It must be 0 or NULL instead of ""
That's all, thanks anyway
This is probably because the file does not exist in the working directory. I would add some code to print the path of the current working directory just before calling sqlite3_open_v2 to be sure.
One difference between sqlite3_open and sqlite3_open_v2 with SQLITE_OPEN_READWRITE is the first one will create an empty database when no file is found, while the second one will not.
In order to allow the creation of a database with sqlite3_open_v2, you should use:
sqlite3_open_v2("database.db", &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL );
Be sure to have a look at the documentation for more information: http://www.sqlite.org/c3ref/open.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With