|
-
May 24th, 2004, 05:52 AM
#1
SQL statement ?
hi there,
I want to get all the table names in MS access.
So what will be SQL statement ?
thanks ahead
rajeev
-
May 24th, 2004, 06:16 AM
#2
Unfortunately, It seems no SQL statement can do this work. I am also looking for some time 
So, my way is to create a root table first containing all the table names in this database. then you can access any table by read this table.
-
May 24th, 2004, 06:18 AM
#3
Do you use DAO ?
if yes, this snippet of code did the trick for me:
database.Open("dbase.mdb");
int iRecords = 0;
int iTotTables = database.GetTableDefCount();
CDaoTableDefInfo tInfo;
CDaoTableDef tb(&database);
int iCount = 0;
for (int n = 0; n < iTotTables; n++)
{
database.GetTableDefInfo(n, tInfo);
LONG attr = tInfo.m_lAttributes;
tb.Open(tInfo.m_strName);
LONG CheckSysObj = tb.GetAttributes();
if((CheckSysObj & dbSystemObject) == 0 && (attr & dbHiddenObject) != dbHiddenObject)
{
try
{
iRecords = tb.GetRecordCount();
//display tablenames
AfxMessageBox(tInfo.m_strName);
}
catch(CDaoException &e)
{
e.ReportError();
}
}
tb.Close();
}
database.Close();
-
May 24th, 2004, 06:27 AM
#4
hi broesli ,
Your code works just fine. thank you very much.
regards
rajeev
-
May 24th, 2004, 06:28 AM
#5
or if you use ADO:
you can get a recordset with information about all tables with the OpenSchema Method of the Connection object
read this:
http://msdn.microsoft.com/library/de...openschema.asp
there are also examples for vc++, vj++ and vb
-
May 24th, 2004, 06:31 AM
#6
no problem,
glad I could help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|