I have a program that accesses a database using SQLite. When I open a OpenFileDialog or a SaveFileDialog before I do the SQLite call:
result = sqlite3_prepare_v2(databaseConnection,converted,10000,&stmt,&strptr);
and choose “Cancel”, everything works okay (result == SQLITE_OK) but when I choose “Open”, even if I don’t do anything with the dialog’s return file, it breaks (result == SQLITE_ERROR). Do you have any idea why this might be happening?
Thanks so much for your time!
EDIT: Here is the code I am using:
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->ShowDialog();
sqlite3_stmt * stmt;
const char * strptr;
sqlite3 * databaseConnection;
int result = sqlite3_open("virtualpatient_chat.db", &databaseConnection);
if (result != SQLITE_OK) return;
result = sqlite3_prepare_v2(databaseConnection,"SELECT * from mappings;",10000,&stmt,&strptr);
if (result != SQLITE_OK) return;
Strangely, it won’t work in my current project but I copied and pasted it into a brand new project and the error doesn’t repeat. Now I’m just trying to figure out what the problem in my surrounding code could be…
I finally figured out how to fix it. Under the Properties for my dialog box, I had to set the RestoreDirectory property to true. I’m not quite sure how that fixed it unless somehow by changing the directory it made SQLite not be able to find my database file.
Thanks for your help!