用Matlab获取Access数据库表的名称 [英] Getting names of Access database tables with Matlab

查看:432
本文介绍了用Matlab获取Access数据库表的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Matlab获取Access数据库中所有表的列表.

I'm trying to get a listing of all tables in an Access database using Matlab.

到目前为止,我正在使用actxobject,并且可以针对数据库成功运行查询,但是我已经阅读了所有方法

I'm so far using an actxobject and can successfull run queries against the database, but all methods I've read here have failed.

我始终收到错误消息"MSysObjects上没有读取权限".该查询在Access程序中运行良好,但是我程序的实现不允许我将查询存储在该程序中.

I consistently get the error message 'No read permission on MSysObjects'. The query runs fine within the Access-program, but the implementation of my program does not allow me to store the query there.

所以,我的问题是:是否可以通过Matlab列出Access数据库的所有表?

So, my question is: Is there any way to list all the tables of an Access database through Matlab?

推荐答案

请考虑以下代码:

conn = actxserver('ADODB.Connection');
connString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Nwind.mdb';
conn.Open(connString);

rs = conn.OpenSchema('adSchemaTables').GetRows;
tableNames = rs(3, ismember(rs(4,:),'TABLE') );

结果是:

>> tableNames'
ans = 
    'Categories'
    'Customers'
    'Employees'
    'Order Details'
    'Orders'
    'Products'
    'Shippers'
    'Suppliers'

这篇关于用Matlab获取Access数据库表的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆