问题
System specs: 64-bit OS (Win7), 64-bit R (3.3.3), 32-bit MS Access (2016).
I have data in a 32-bit .accdb file and I want to read it into R. I tried this:
con <- odbc::dbConnect(odbc::odbc(),
dsn="MS Access Database")
but saw the following error:
Error: nanodbc/nanodbc.cpp:950: IM014: [Microsoft][ODBC Driver Manager]
The specified DSN contains an architecture mismatch between the Driver and Application
Web search indicated that the bit difference between R and the database is the culprit. The default ODBC manager in Windows doesn't include drivers for MS Access (or rather, it seems to, but attempting to manage them using that tool gives you an architecture error). Following other advice, I used the ODBC manager for 32-bit programs (c:\windows\sysWOW64\odbcad32.exe) to create a new DSN with a new name for MS Access files, and then called this DSN:
con <- odbc::dbConnect(odbc::odbc(),
dsn="MSAccess32")
I got the same error, however, and suspect there is something I don't understand about what this error means. Is there a known workaround for the problem?
回答1:
The access file itself knows nothing about bitness, its only about the client application and the bitness of the odbc driver:
If your R is 64 bit, you need the 64bit ODBC driver for access and therefore also use the odbc manager for 64bit, which is C:\Windows\System32\odbcad32.exe
(in Win7 64bit).
While if your R is 32bit, you need the 32bit ODBC driver, located at C:\Windows\SysWOW64\odbcad32.exe
.
You can download the required Access Database Engine 2010 Redistributable from here: https://www.microsoft.com/en-US/download/details.aspx?id=13255
So, download the 64 bit Access Database driver, create a 64bit DSN entry and you should be fine.
来源:https://stackoverflow.com/questions/45064057/reading-data-from-32-bit-access-db-using-64-bit-r