将 32 位 R 连接到 32 位 Access 数据库

Connecting 32-bit R to a 32-bit Access database

我正在使用 32 位 R 和 RStudio 来尝试连接到 .accdb 文件。我的机器上有 32 位 MS Access 运行。

R 版本:

platform       i386-w64-mingw32            
arch           i386                        
os             mingw32                     
system         i386, mingw32               
status                                     
major          3                           
minor          1.2                         
...
language       R                           
version.string R version 3.1.2 (2014-10-31)
nickname       Pumpkin Helmet

我正在尝试使用 RODBC 程序包连接到 MS Access 数据库。我无法使用 odbcConnectAccess("location_of_database.accdb") 连接到客户端提供的数据库。这个特定的数据库是使用 Access 2013 创建的。当我尝试连接时,我收到各种警告消息:

Warning messages:
1: In odbcDriverConnect(con, ...) :
  [RODBC] ERROR: state HY000, code -1028, message [Microsoft][ODBC Microsoft     Access Driver] Cannot open database '(unknown)'.  It may not be a database that     your application recognizes, or the file may be corrupt.
2: closing unused RODBC handle 12 
3: In odbcDriverConnect(con, ...) :
  [RODBC] ERROR: state 01000, code 1, message [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x11a4 Thread 0x798 DBC 0x88e0064 Jet'.
4: In odbcDriverConnect(con, ...) :
  [RODBC] ERROR: state 01000, code 1, message [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x11a4 Thread 0x798 DBC 0x88e0064 Jet'.
5: In odbcDriverConnect(con, ...) : ODBC connection failed

有趣的是,我可以使用 odbcConnectAccess2007() 成功连接到使用 Access 2010 创建的数据库;但是,当我尝试使用 odbcConnectAccess() 连接到那些相同的数据库时,我得到了上面相同的错误。

Google 搜索上面的 Error: state 01000, code 1 消息表明 this page 可能有帮助,但即使按照步骤更改 HKEY_LOCAL_MACHINE 也不起作用。

虽然我最初认为 that this question was promising,但那里的警告消息与 "ACE DSN" 有关,而我看到的错误消息与 "Jet DSN."

有关

我无法使用我的 Access 版本打开我尝试使用 RODBC 访问的数据库,因为这些数据库是使用 Access 2013 创建的,并且我安装了 Access 2010。

任何人都可以帮我解决为什么我不能用 odbcConnectAccess() 打开这个数据库吗?

why I can't open this [Access 2013] database with odbcConnectAccess()?

我相当确定

odbcConnectAccess(<fileSpec>)

只是 shorthand 对于

odbcDriverConnect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=<fileSpec>')

(即较旧的 "Jet" ODBC 驱动程序)和

odbcConnectAccess2007(<fileSpec>)

只是 shorthand 对于

odbcDriverConnect('DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=<fileSpec>')

(即较新的 "ACE" ODBC 驱动程序)。

较旧的 "Jet" 驱动程序无法处理 .accdb 文件,因此需要 odbcConnectAccess2007()。如果抛出 "Unrecognized database format" 错误,则可能是数据库文件已损坏。