问题描述
我在RStudio中使用32位R
尝试连接到.accdb
文件.我的计算机上运行了32位MS Access.
I am using 32-bit R
with RStudio to try and connect to an .accdb
file. I have 32-bit MS Access running on my machine.
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创建的.当我尝试连接时,会收到各种警告消息:
I'm trying to use the RODBC
package to connect to an MS Access database. I cannot use odbcConnectAccess("location_of_database.accdb")
to connect to a database provided by a client. This particular database was created with Access 2013. When I try to connect, I get a variety of warning messages:
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()
连接到这些相同的数据库时,上面出现的错误也相同.
Interestingly, I can use odbcConnectAccess2007()
to connect successfully to databases that were created with Access 2010; however, when I try to use odbcConnectAccess()
to connect to those same databases, I get the same errors above.
Google对上述Error: state 01000, code 1
消息的搜索表明此页面可能会有所帮助,但是即使按照更改HKEY_LOCAL_MACHINE
的步骤进行操作之后,也无法正常工作.
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.
虽然我最初以为这个问题是有前途的,警告消息与"ACE DSN"有关,而我看到的错误消息与"Jet DSN"有关.
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."
我无法使用我的Access版本打开要使用RODBC
访问的数据库,因为这些数据库是使用Access 2013创建的,并且我已经安装了Access 2010.
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.
有人可以帮我解决为什么我无法使用odbcConnectAccess()
打开此数据库的问题吗?
Can anyone help me trouble shoot why I can't open this database with odbcConnectAccess()
?
推荐答案
我相当确定
odbcConnectAccess(<fileSpec>)
简直是
odbcDriverConnect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=<fileSpec>')
(即较旧的"Jet" ODBC驱动程序)和
(i.e., the older "Jet" ODBC driver), and
odbcConnectAccess2007(<fileSpec>)
简直是
odbcDriverConnect('DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=<fileSpec>')
(即,较新的"ACE" ODBC驱动程序).
(i.e., the newer "ACE" ODBC driver).
较旧的"Jet"驱动程序无法使用.accdb文件,因此需要odbcConnectAccess2007()
.如果该错误引发无法识别的数据库格式"错误,则很可能是数据库文件已损坏.
The older "Jet" driver cannot work with .accdb files, so odbcConnectAccess2007()
would be required. If that throws an "Unrecognized database format" error then it's likely that the database file is damaged.
这篇关于将32位R连接到32位Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!