kacor
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
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
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(Li stBox1.Ite ms);
with ADO
// ConnectionString will point to your .mdb file
AdoConnection1.ConnectionS tring := 'Provider=Microsoft.Jet.OL EDB.4.0;Da ta 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.GetTableNam es(ListBox 1.Items,Fa lse);
Regards,
Mohammed
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(Li
with ADO
// ConnectionString will point to your .mdb file
AdoConnection1.ConnectionS
AdoConnection1.Open();
//GetTableNames will bring all the tables in your mdb file, use False to not show the sytem tables
AdoConnection1.GetTableNam
Regards,
Mohammed
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
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
ASKER
AmigoJack,
sorry but your comment didn't appeared only the message from Mohammed. Thanks for your comment too!!
Janos
sorry but your comment didn't appeared only the message from Mohammed. Thanks for your comment too!!
Janos
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
Everything ok. I forgot to set the user/pw
thanks!
Janos
thanks!
Janos
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...