Error Connecting to Access Database

8 次查看(过去 30 天)
Jim
Jim 2014-8-28
I am attempting to connect to a MS Access database from Matlab Ver 7.12.0.635 (2011a) but I get an error in con.Message. I performed the following:
dbpath='C:\Users\g553586\Documents\Database1.accdb';
url = [['jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='''';DBQ='] dbpath];
con = database('','','','sun.jdbc.odbc.JdbcOdbcDriver', url);
con
con =
Instance: ''
UserName: ''
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: '[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified'
Handle: 0
TimeOut: []
AutoCommit: 'off'
Type: 'Database Object'

回答(2 个)

Jim
Jim 2014-9-8
I attempted a different configuration. I defined an ODBC connection to an Access database test.accdb. and called it test_db. In the Matlab command window, I performed the following:
conn = database('test_db','','');
conn.message
ans =
[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application Please verify that login information and database url are valid.
I researched the error message in Matlab help and found the following: "You tried to open a 32-bit application when running MATLAB® in 64-bit mode." and recommended resolution "Restart MATLAB to run in 32-bit mode using the command matlab –win32." However, when I run that command, Matlab always appears to run in 64-bit mode and I continue to get the same error message. I cannot find any other information on running in 32-bit mode. BR Is there another way to force running in 32-bit mode so that I can connect to the 32-bit Access db? Is there another work around? I am running this on a machine that is fairly locked down so I will have to go through a help desk to make changes to the installation.
  1 个评论
Jim
Jim 2014-9-8
I requested the 32-bit version of Matlab to be installed. I will have to wait a couple days for that to happen. If there is another work around, please post it. Thanks.

请先登录,再进行评论。


Bereketab Gulai
Bereketab Gulai 2020-5-20

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by