wxDatabase and .accdb files Topic is solved

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
Post Reply
Kerry
Experienced Solver
Experienced Solver
Posts: 58
Joined: Fri Mar 07, 2008 5:44 pm

wxDatabase and .accdb files

Post 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
Kerry
Experienced Solver
Experienced Solver
Posts: 58
Joined: Fri Mar 07, 2008 5:44 pm

Re: wxDatabase and .accdb files

Post 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
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: wxDatabase and .accdb files

Post 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 pmAlso, 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!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Kerry
Experienced Solver
Experienced Solver
Posts: 58
Joined: Fri Mar 07, 2008 5:44 pm

Re: wxDatabase and .accdb files

Post by Kerry »

Post Reply