简体   繁体   English

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

[英]Connecting 32-bit R to a 32-bit Access database

I am using 32-bit R with RStudio to try and connect to an .accdb file.我在 RStudio 中使用 32 位R来尝试连接到.accdb文件。 I have 32-bit MS Access running on my machine.我的机器上运行着 32 位 MS Access。

R version: 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

I'm trying to use the RODBC package to connect to an MS Access database.我正在尝试使用RODBC包连接到 MS Access 数据库。 I cannot use odbcConnectAccess("location_of_database.accdb") to connect to a database provided by a client.我无法使用odbcConnectAccess("location_of_database.accdb")连接到客户端提供的数据库。 This particular database was created with Access 2013. When I try to connect, I get a variety of warning messages:这个特定的数据库是用 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

Interestingly, I can use odbcConnectAccess2007() to connect successfully to databases that were created with Access 2010 ;有趣的是,我可以使用odbcConnectAccess2007()成功连接到使用Access 2010创建的数据库; however, when I try to use odbcConnectAccess() to connect to those same databases, I get the same errors above.但是,当我尝试使用odbcConnectAccess()连接到这些相同的数据库时,我遇到了上述相同的错误。

A Google search of the Error: state 01000, code 1 message above suggests that this page may be helpful, but even after following the steps to alter the HKEY_LOCAL_MACHINE does not work. Google 搜索Error: state 01000, code 1上面的Error: state 01000, code 1消息表明此页面可能会有所帮助,但即使按照更改HKEY_LOCAL_MACHINE的步骤也不起作用。

While I originally thought that this question was promising , the warning message there relates to "ACE DSN" while the error messages I'm seeing relate to "Jet DSN."虽然我最初认为这个问题很有希望,但那里的警告消息与“ACE DSN”有关,而我看到的错误消息与“Jet DSN”有关。

I cannot open the databases I'm trying to access with RODBC with my version of Access as the databases were created with Access 2013 and I have Access 2010 installed.我无法使用我的 Access 版本打开我尝试使用RODBC访问的数据库,因为这些数据库是使用 Access 2013 创建的,并且我安装了 Access 2010。

Can anyone help me trouble shoot why I can't open this database with odbcConnectAccess() ?谁能帮我解决为什么我不能用odbcConnectAccess()打开这个数据库?

why I can't open this [Access 2013] database with odbcConnectAccess() ?为什么我不能用odbcConnectAccess()打开这个 [Access 2013] 数据库?

I'm fairly certain that我相当确定

odbcConnectAccess(<fileSpec>)

is simply shorthand for只是简写

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

(ie, the older "Jet" ODBC driver), and (即,较旧的“Jet”ODBC 驱动程序),以及

odbcConnectAccess2007(<fileSpec>)

is simply shorthand for只是简写

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

(ie, the newer "ACE" ODBC driver). (即,较新的“ACE”ODBC 驱动程序)。

The older "Jet" driver cannot work with .accdb files, so odbcConnectAccess2007() would be required.较旧的“Jet”驱动程序无法使用 .accdb 文件,因此需要odbcConnectAccess2007() If that throws an "Unrecognized database format" error then it's likely that the database file is damaged.如果这引发“无法识别的数据库格式”错误,则很可能是数据库文件已损坏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM