display the list of tables in a mysql database
-
how to display the list of tables in a mysql database, I have at my application module that requires selection of the database and selection of the table that will display its contents
-
how to display the list of tables in a mysql database, I have at my application module that requires selection of the database and selection of the table that will display its contents
You need to execute a query against the db. Something like
SHOW [FULL] TABLES [{FROM | IN} db_name]
[LIKE 'pattern' | WHERE expr]Go look at http://dev.mysql.com/doc/[^] to find the correct syntax for the version you are working on. Maybe execute it as a stored proc and return it to your application.
-
how to display the list of tables in a mysql database, I have at my application module that requires selection of the database and selection of the table that will display its contents
You need to query the Information_Schema database, something like this:-
SELECT Table_Name FROM Information_Schema.Tables WHERE Table_Type = 'BASE TABLE' AND Table_Schema = 'yourSchema'
This will give you the names of all the tables in your schema.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
-
how to display the list of tables in a mysql database, I have at my application module that requires selection of the database and selection of the table that will display its contents
You don't need any SQL:
public override List GetTableNames() {
using (OleDbConnection con=new OleDbConnection(connectionString)) {
con.Open();
DataTable dt=con.GetSchema("Tables");
List tableNames=new List();
foreach (DataRow row in dt.Rows) {
string tableName=(string)row["TABLE_NAME"];
tableNames.Add(tableName);
}
return tableNames;
}
}:)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
You don't need any SQL:
public override List GetTableNames() {
using (OleDbConnection con=new OleDbConnection(connectionString)) {
con.Open();
DataTable dt=con.GetSchema("Tables");
List tableNames=new List();
foreach (DataRow row in dt.Rows) {
string tableName=(string)row["TABLE_NAME"];
tableNames.Add(tableName);
}
return tableNames;
}
}:)
Luc Pattyn [My Articles] Nil Volentibus Arduum
thank you :)
-
You don't need any SQL:
public override List GetTableNames() {
using (OleDbConnection con=new OleDbConnection(connectionString)) {
con.Open();
DataTable dt=con.GetSchema("Tables");
List tableNames=new List();
foreach (DataRow row in dt.Rows) {
string tableName=(string)row["TABLE_NAME"];
tableNames.Add(tableName);
}
return tableNames;
}
}:)
Luc Pattyn [My Articles] Nil Volentibus Arduum
I've never tried to access MySql with OleDb; I've always used the MySql .net connector. On a MySql database I access at work that doesn't work :sigh: -- it seems it may be an older version of MySql.
-
I've never tried to access MySql with OleDb; I've always used the MySql .net connector. On a MySql database I access at work that doesn't work :sigh: -- it seems it may be an older version of MySql.
-
I've never tried to access MySql with OleDb; I've always used the MySql .net connector. On a MySql database I access at work that doesn't work :sigh: -- it seems it may be an older version of MySql.
yes i chenged OLEDB with Mysql and it work
-
I've never tried to access MySql with OleDb; I've always used the MySql .net connector. On a MySql database I access at work that doesn't work :sigh: -- it seems it may be an older version of MySql.
My mistake. That was a code snippet I once used on Access. I trust the same approach works just fine on MySQL, mutatis mutandis. :-O
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
My mistake. That was a code snippet I once used on Access. I trust the same approach works just fine on MySQL, mutatis mutandis. :-O
Luc Pattyn [My Articles] Nil Volentibus Arduum
My problem was my mistake as well... the userID I was given only has access to views, so of course they didn't show up when I asked for tables. :doh:
-
You don't need any SQL:
public override List GetTableNames() {
using (OleDbConnection con=new OleDbConnection(connectionString)) {
con.Open();
DataTable dt=con.GetSchema("Tables");
List tableNames=new List();
foreach (DataRow row in dt.Rows) {
string tableName=(string)row["TABLE_NAME"];
tableNames.Add(tableName);
}
return tableNames;
}
}:)
Luc Pattyn [My Articles] Nil Volentibus Arduum
can I use the same function to show the list of databases names?