Link to home
Start Free TrialLog in
Avatar of kacor
kacorFlag for Hungary

asked on

Table names and number of rows

Hi Experts,

after selecting the database I'd like to get the table names of this database into a grid with the actual number of it's rows. Could somebody help me?

wbr Janos
Avatar of AmigoJack
AmigoJack

that is a question on which dbms you rely.

on mysql you can use the queries SHOW TABLES; and DESC TABLE_NAME;
on oracle you have to use the queries SELECT TABLE_NAME FROM USER_ALL_TABLES; and DESC TABLE_NAME;

those queries come up with all table names and then all table collumns. if you mean "with the actual number of it's rows" that you only want to count tupels of each table, use SELECT COUNT(*) FROM TABLE_NAME; instead of DESC...
Avatar of Mohammed Nasman
Hello,

Are you using BDE, ADO or what?, and which DB?

here's code to help you to return the table names using BDE and ADO, then you could easily know the number of records for each table by using "select count(*) from mytable"

for BDE, then you could use GetTableNames method to return the list of selected DB

  Database1.Aliasname := 'DBDEMOS';
  Database1.DatabaseName :='DB';
  DataBase1.GetTableNames(ListBox1.Items);

with ADO

// ConnectionString will point to your .mdb file
  AdoConnection1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDb.mdb';
  AdoConnection1.Open();

//GetTableNames will bring all the tables in your mdb file, use False to not show the sytem tables
  AdoConnection1.GetTableNames(ListBox1.Items,False);

Regards,
Mohammed
Avatar of kacor

ASKER

Hi Mohammed,

thanks for your quick answer. I forgot to tell I use Interbase. I connect to the database with IBX components (D7 Interbase menu) and this method don't work. I tried to use the TSession but in this environment don't work too :-(

Janos
Avatar of kacor

ASKER

AmigoJack,
 
sorry but your comment didn't appeared only the message from Mohammed. Thanks for your comment too!!

Janos
ASKER CERTIFIED SOLUTION
Avatar of josmx
josmx

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kacor

ASKER

Hi Jesus Obregon,

thanks for your help. I tried to run your solution above. I'm sure this is the good solution but I get the following error message:

---------------------------
Debugger Exception Notification
---------------------------
Project XX.exe raised exception class EIBClientError with message 'Operation cancelled at user's request'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------

I don't made cancel. I don't understand this message.

Janos
Avatar of kacor

ASKER

Everything ok. I forgot to set the user/pw

thanks!
Janos