Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Create Access Database in Matlab using active x server

Subject: Create Access Database in Matlab using active x server

From: Molly

Date: 24 Sep, 2012 21:05:11

Message: 1 of 3

I have been using the following commands to use an existing Microsoft Access database:
fn = 'test.accdb';
svr = actxserver('access.application');
adb = svr.DbEngine.OpenDatabase(fname);

This works great. How do I create a new database? I have tried the following:
svr.Application.DBEngine.CreateDatabase('test2.accdb')
I get the following error:
No method 'CreateDatabase' with matching signature found for class
'Interface.Microsoft_DAO_3.6_Object_Library._DBEngine'.

Any ideas?

Subject: Create Access Database in Matlab using active x server

From: Ryan

Date: 21 Oct, 2012 18:59:08

Message: 2 of 3

You want to use m-code to CREATE a new database? Hummmm, not sure you can do that. Why not just create the DB, using MS Access itself, and do your database stuff in your database. THEN, connect to the DB and do your Matlab stuff in Matlab. That's how I'd do it. Check out these links for some ideas of how to use Matlab to connect to Access:
http://www.tristanfletcher.co.uk/Matlab%20Access.pdf
http://www.mathworks.com/help/database/ug/database.html
http://www.mathworks.com/matlabcentral/newsreader/view_thread/277424



"Molly " <matlabquestions@gmail.com> wrote in message <k3qhu7$r31$1@newscl01ah.mathworks.com>...
> I have been using the following commands to use an existing Microsoft Access database:
> fn = 'test.accdb';
> svr = actxserver('access.application');
> adb = svr.DbEngine.OpenDatabase(fname);
>
> This works great. How do I create a new database? I have tried the following:
> svr.Application.DBEngine.CreateDatabase('test2.accdb')
> I get the following error:
> No method 'CreateDatabase' with matching signature found for class
> 'Interface.Microsoft_DAO_3.6_Object_Library._DBEngine'.
>
> Any ideas?

Subject: Create Access Database in Matlab using active x server

From: Phil Goddard

Date: 21 Oct, 2012 21:43:08

Message: 3 of 3

According to the CreateDatabase doc you must supply a second argument (that specifies a locale).

Within VBA this would be something like
Application.DBEngine.CreateDatabase('test2.accdb',dbLangGeneral)

Since MATLAB doesn't recognize the dbLangGeneral constant (nor its cousins) you need to do a little work to find what that (string) constant is defined as.

It seems that the following works:
>> svr = actxserver('Access.Application');
>> createdDB = svr.DBEngine.CreateDatabase('test2.mdb',';LANGID=0x0409;CP=1252;COUNTRY=0');

Phil.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us