Page 1 of 1

wxDatabase and .accdb files

Posted: Tue Jun 11, 2019 8:50 pm
by Kerry
Hello,

Is it possible to use wxDatabase with .accdb files via ODBC? Or another connection type?

I found a couple connection strings which include references to the .mdb format, but I'm not familiar enough with databases to know if I should expect this connection string to work or not. I've tried this:

Code: Select all

db = new wxOdbcDatabase();
db->Open(_T("Driver={Microsoft Access Driver (*.mdb)};Dbq=") + databaseLocation + _T(";Uid=Admin;Pwd=;"));
and it throws an exception.

From briefly looking through the source, it looks like ODBC connections could possibly require DbType and DSN parameters - is this correct? If so, how can I determine the correct values?

Thanks,

Kerry

Re: wxDatabase and .accdb files

Posted: Wed Jun 12, 2019 1:47 pm
by Kerry
I'll answer my own question: It turns out I was having a bitness issue - I was compiling a 32-bit application but only had 64-bit ODBC drivers installed on my system. There were some tricks to get it working, but Jon Raiford's answer here was helpful:

https://social.technet.microsoft.com/Fo ... oappcompat

Also, when catching exceptions from wxDatabase, you need to catch wxDatabaseException (so you can see the error messages). I was trying to catch std::exception, assuming that any wx exceptions would be derived from std::exception, but apparently that isn't the case.

-Kerry

Re: wxDatabase and .accdb files

Posted: Mon Jun 17, 2019 8:46 am
by evstevemd
Hi Kerry,
Kerry wrote:
Wed Jun 12, 2019 1:47 pm
I'll answer my own question: It turns out I was having a bitness issue - I was compiling a 32-bit application but only had 64-bit ODBC drivers installed on my system. There were some tricks to get it working, but Jon Raiford's answer here was helpful:

https://social.technet.microsoft.com/Fo ... oappcompat
I missed your question. Happy to see one more user of wxDatabase.
Great that your query was solved!
Kerry wrote:
Wed Jun 12, 2019 1:47 pm
Also, when catching exceptions from wxDatabase, you need to catch wxDatabaseException (so you can see the error messages). I was trying to catch std::exception, assuming that any wx exceptions would be derived from std::exception, but apparently that isn't the case.

-Kerry
Can you open an issue on that? I will definitely look at it when I find time and make it as "std" as possible!

Re: wxDatabase and .accdb files

Posted: Tue Jun 18, 2019 2:51 pm
by Kerry