Solved

Table Info of a mdb database!!!

Posted on 2000-03-07
5
224 Views
Last Modified: 2013-11-20
Hi,

I have used the following code to get table info from my database.
My database contains only one table.
I don't know why the index value must be set to 4 in order to get the name of the table.

Can anyone tell me what is the use of the value index?
If my database contain only one table, why I can't get the name of the table by setting the value of index equal to 0.

--------------------------------------------------------------------------
CDaoTableDefInfo TableInfo;
int index=0;
BOOL lp= TRUE;
while (lp)
{
m_pDBList->GetTableDefInfo(index,TableInfo,AFX_DAO_ALL_INFO);
if (!(TableInfo.m_lAttributes & dbSystemObject)&& !(TableInfo.m_lAttributes & dbHiddenObject))
{
break;
}
  index++;
}

--------------------------------------------------------------------------


Thanks!!!
0
Comment
Question by:ee_lcpaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2594702
Hi

Index is just a look up number of the perticular tabledef collection in the database it doesn't have to do any thing with the number of tables present in the database.
0
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2594975
inpras is probably correct.

There are also hidden and system tables, correct? I am only guessing, but perhaps they use index values that are less than 4.
0
 
LVL 3

Expert Comment

by:SamHobbs
ID: 2594980
I forgot to mention something. Did you try doing something like setting a breakpoint on the if statement after the GetTableDefInfo call to see what the results were for indexes 0 to 4?
0
 
LVL 3

Expert Comment

by:V_Bapat
ID: 2594990
I am not sure about this but...
It may be so that 5 tables were created and the first 4 were deleted.

Can you try creating this table and then get the table info?
0
 
LVL 3

Accepted Solution

by:
V_Bapat earned 40 total points
ID: 2595073
These are the first 4 system tables:

Index   Table name
 0        MSysACEs
 1        MySysObjects
 2        MySysQueries
 3        MySysRelationships

That is why your table index is 4.

If you want to get only the user tables, you can try something like this:

CDaoTableDefInfo tdiTableInfo;
long lTableCount = m_pDBList->GetTableDefCount();

for(int i = 0; i < lTableCount; i++)
{
   m_pDBList->GetTableDefInfo(i, tdiTableInfo, AFX_DAO_ALL_INFO);

   if(tdiTableInfo.m_lAttributes & dbSystemObject | tdiTableInfo.m_lAttributes & dbHiddenObject)
      continue;

// tdiTableInfo.m_strName contains the table name.
// Display it.
   AfxMessageBox(tdiTableInfo.m_strName);
}

Vicky
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to know only "File created" with EventLog 3 35
move a line in eclipse 3 111
Adjust the codes 3 63
Notepad++ Question 11 28
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question