ChatterBank0 min ago
Answers
Best Answer
No best answer has yet been selected by Potatoman. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.Info on the SQL you will need to run against MySQL :
http://dev.mysql.com/doc/refman/5.0/en/tables- table.html
To run this and get the data, you need a Command object and a DataReader object from whichever data provider you are using.
The DataReader object should have a HasRows property and a Read method which you can use to pull the data.
if(dr.HasRows)
{
while(dr.Read())
{
string tableName = dr["table_name"].Value;
// .. other processing
}
}
If you want to bind to a DataGrid, then you need to use a DataAdapter and a DataSet
Need more info on how you're connecting to MySQL to give more info really.
http://dev.mysql.com/doc/refman/5.0/en/tables- table.html
To run this and get the data, you need a Command object and a DataReader object from whichever data provider you are using.
The DataReader object should have a HasRows property and a Read method which you can use to pull the data.
if(dr.HasRows)
{
while(dr.Read())
{
string tableName = dr["table_name"].Value;
// .. other processing
}
}
If you want to bind to a DataGrid, then you need to use a DataAdapter and a DataSet
Need more info on how you're connecting to MySQL to give more info really.
...
using MySql.Data;
using MySql.Data.MySqlClient;
...
string[] tableNames = null;
MySqlConnection conn = new MySqlConnection("Server=localhost;Database=test;Uid=kallidus;Pwd=password");
MySqlCommand cmd = new MySqlCommand("SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='Test'", conn);
conn.Open();
MySqlDataReader dr = cmd.ExecuteReader();
if(dr.HasRows)
{
ArrayList alTableNames = new ArrayList();
while(dr.Read())
alTableNames.Add(dr["table_name"].ToString());
tableNames = (string[])alTableNames.ToArray(typeof(string));
}
if(tableNames!=null)
{
foreach(string tableName in tableNames)
MessageBox.Show(tableName);
}
else
{
MessageBox.Show("No table names returned.");
}
using MySql.Data;
using MySql.Data.MySqlClient;
...
string[] tableNames = null;
MySqlConnection conn = new MySqlConnection("Server=localhost;Database=test;Uid=kallidus;Pwd=password");
MySqlCommand cmd = new MySqlCommand("SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='Test'", conn);
conn.Open();
MySqlDataReader dr = cmd.ExecuteReader();
if(dr.HasRows)
{
ArrayList alTableNames = new ArrayList();
while(dr.Read())
alTableNames.Add(dr["table_name"].ToString());
tableNames = (string[])alTableNames.ToArray(typeof(string));
}
if(tableNames!=null)
{
foreach(string tableName in tableNames)
MessageBox.Show(tableName);
}
else
{
MessageBox.Show("No table names returned.");
}
-- answer removed --
-- answer removed --
-- answer removed --