4.6

4.6 | 10 ratings Rate this file 58 downloads (last 30 days) File Size: 12.03 KB File ID: #13621

ADO OLE Database Connection

by Martin Furlan

 

10 Jan 2007 (Updated 10 Jan 2007)

No BSD License  

Queries datasource and insers data into datasource.

Download Now | Watch this File

File Information
Description

This code basis on Tim Myers code (oledb*.m) and uses ADO OLE DB instead of OWC - Office Web Component. When OWC not installed (e.g. MS Office 2000) using ADO OLE DB can be a solution. The syntax is similar to Tim Myers code.

The Code is tested only with MS Access database.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
database connection mfiles

MATLAB release MATLAB 7.3 (R2006b)
Zip File Content  
Other Files adodb/adodbcn.m,
adodb/adodbcnstr.m,
adodb/adodbinsert.m,
adodb/adodbquery.m,
adodb/adodb_demo.m,
adodb/adotest.mdb
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
26 Apr 2007 Ryan Schaezler

Works well. I was having problems with OWC even though it was install on one computer. Using the ADODB connection worked without any issues.

26 Oct 2007 Martijn Koopman

Very easy to use and extremely fast interface with Microsoft Access *.MDB files.

04 Jan 2008 Christy Lynch

This is a fantastically easy interface to use for Access databases. The problem is a memory leak. Releasing the connection and clearing the connection variable does not release the memory used up by the connection. Only restarting Matlab seems to work.

27 Feb 2008 jairo Ortiz  
22 Mar 2008 hardik nadiyana

really help ful thanx,
hardik

25 Jul 2008 Laszlo Sragner

h=actxserver('ADODB.Connection');
h.Open(connstr);
res=h.Execute(sqlstr);
x=res.GetRows()';
h.Close();
delete(h);

Maybe the leak was due to the 'release' command at the end instead of 'delete'

28 Aug 2008 deepa deepa  
23 Sep 2008 Jasleen K.

Thanks a tonne..!!!!
solved my problem.!!

14 Oct 2008 Leen K.

want to use variables in the sql queries...
kindly suggest a way.
e.g. sql=['select * from TestTable where firstname=',myname ,'];
5this statement wont replace variable myname

24 Feb 2009 Guyennon Nicolas

Thanks a lot !!! Amazing work, even faster than Tim Myers code (oledb*.m)
I'm working with your toolbox to query access 2003 database.
I was looking for table, field and query information. Tooks me 4 days ... hope that could help someone else

%% get table name
sqltablename='SELECT name FROM MSysObjects WHERE Type=1 AND Flags=0 ORDER BY name';
tablename=adodbquery(cn,sqltablename);
%% get query name
sqlqueryname='SELECT name FROM MSysObjects WHERE Type=5 AND Flags=0 ORDER BY name';
queryname=adodbquery(cn,sqlqueryname);

note that in both case you should first change users authorization to read for MSysObjects opening your access database. ("user and group authorization" menu in tools)

the hardest part was to get fields or columns name ...

function field_name=tablefieldname(cn,table_name)
%% find all field name from table
sqlfiledname=['SELECT * FROM ' table_name];
invoke(cn,'BeginTrans');
r = invoke(cn,'Execute',sqlfiledname);
invoke(cn,'CommitTrans');
nbfileds=r.Fields.count;field_name='';
for ff=1:nbfileds
    fld=r.Fields.Item(ff-1);
    field_name=strvcat(field_name,fld.name);
end

bye
Nico

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data import Martin Furlan 22 Oct 2008 08:56:10
data export Martin Furlan 22 Oct 2008 08:56:10
database Martin Furlan 22 Oct 2008 08:56:10
query Martin Furlan 22 Oct 2008 08:56:10
insert Martin Furlan 22 Oct 2008 08:56:10
oracle Martin Furlan 22 Oct 2008 08:56:10
datasource Martin Furlan 22 Oct 2008 08:56:10
access Martin Furlan 22 Oct 2008 08:56:10
sql Martin Furlan 22 Oct 2008 08:56:10
database Howell 25 Feb 2009 14:10:22
sql Howell 25 Feb 2009 14:10:38
oracle Martijn 01 Sep 2009 08:52:14
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com