By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

How to get table names from ms access(mdb file) by using odbclibrary.

P: n/a
JS

Hi.

I am writing a c++ program get the data from mdb file using odbc
library.
By the way, I couldn't get table list from mdb file.
i goolgled it up little bit, what i found is only using the ADO(or OLE
i'm not sure) library and
"SELECT Name FROM MSysObjects WHERE Type In (1,4,6) AND Left([Name],
4)<>"MSYS" this query.
i already wrote a lot of part of this program so i don't want to
switch database library.
And the query gives "no read permission on 'MSysObjects' " error
message.

If you know how to get the table list from a mdb file by using odbc
library, please share your experience.

thank you.

Aug 8 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If you using odbc to a mdb file, then you MUST have jet installed, and
THEREFORE you MUST also have dao installed on your machine (in fact, out of
the box, windows xp, server 2003, vista etc DOES HAVE the jet database
engine installed by default (thus you don't need to install anything on a
windows computer to read mdb files.

here is a windows (vbs) script that displays all tables...you can use late
binding in your project, and you should little trouble getting a list of
tables using the following idea.

Set dbeng = CreateObject("DAO.DBEngine.36")
strMdbFile = "C:\Documents and Settings\Lawrence\My
Documents\Access\ScriptExample\MultiSelect.mdb"
Set db = dbeng.OpenDatabase(strMdbFile)
for each table in db.tabledefs
msgbox table.name
next

The above is not a vba script. Paste the above into a text document, and
then re-name the extension as .vbs. If you double click on this file...you
see it list the tables in the given mdb file..

So there is a table collection available after you open the mdb file as per
above...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 9 '08 #2

P: n/a
On Aug 9, 3:04*am, "Albert D. Kallal" <PleaseNOOOsPAMmkal...@msn.com>
wrote:
If you using odbc to a mdb file, then you MUST have jet installed, and
THEREFORE you MUST also have dao installed on your machine (in fact, out of
the box, windows xp, server 2003, vista etc DOES HAVE the jet database
engine installed by default (thus you don't need to install anything on a
windows computer to read mdb files.

here is a windows (vbs) script that displays all tables...you can use late
binding in your project, and you should little trouble getting a list of
tables using the following idea.

Set dbeng = CreateObject("DAO.DBEngine.36")
strMdbFile = "C:\Documents and Settings\Lawrence\My
Documents\Access\ScriptExample\MultiSelect.mdb"
Set db = dbeng.OpenDatabase(strMdbFile)
for each table in db.tabledefs
* *msgbox table.name
next

The above is not a vba script. Paste the above into a text document, and
then re-name the extension as .vbs. If you double click on this file...you
see it list the tables in the given mdb file..

So there is a table collection available after you open the mdb file as per
above...

--
Albert D. Kallal * *(Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKal...@msn.com

"Paste the above into a text document, and
then re-name the extension as .vbs."

Or save file in Notepad with quotes, like:

"TableNames.VBS" (including quotes)

will save file without .TXT extension. :)

Regards,
Branislav Mihaljev
Microsoft Access MVP
Aug 13 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.