I'm currently developing a software with C++ Builder(which is not related to the problem I think), and I have to use a database. I've decided to use SQLite, so I imported a SQLite amalgamation to my project.
I want to store my .db file in the dedicated folder of my application, in the Documents folder. However, when I decide to open a SQLite database in that folder, and create a table, there is no file created, when there is one if I open it in the current folder of the executable, or in C:\test for instance. But the strangest thing is that the database seems to work even without any file, and even when I delete the whole folder, and try to create the same table again, it's written that it already exists.
I'm sure of the path because I use the same for saving some files and that works with no problem. For the same reason, there can't be a problem of admin right.
Here is the interesting lines of the code :
char* userdir = getenv("USERPROFILE");
if (userdir) {
char *zErrMsg = 0;
sqlite3 *db;
int rc;
char *sql;
String docdir(userdir);
docdir = docdir + "\\Documents\\MySoftware\\";
CreateDirectory(docdir.c_str(), 0);
rc = sqlite3_open((char *)(docdir + "test.db").c_str(), &db);
sql = "CREATE TABLE TEST(" \
"ID INT PRIMARY KEY NOT NULL," \
"NAME TEXT NOT NULL," \);";
/* Execute SQL statement */
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
sqlite3_close(db);
}
Maybe I missed something obvious, but I don't see how this is possible. Do you have any idea? Thank you.
Aucun commentaire:
Enregistrer un commentaire