i'm just trying to retrieve the column names of a table in a database. the SQL query i've written (which works in phpMyAdmin) is:
query = "SELECT column_name FROM information_schema.columns WHERE table_schema='hf_framework' AND table_name='elements'";
my code is as follows:
connection = new MySqlConnection(connectionString);
connection.Open();
MySqlCommand cmd = new MySqlCommand(query, connection);
MySqlDataReader dataReader = cmd.ExecuteReader();
while (dataReader.Read()) {
//stuff in there
}
dataReader.Read() always returns false and i never enter the while loop.
if, however, i change the query to:
query = "SELECT column_name FROM information_schema.columns";
...then i do enter into the while loop. what am i missing? thanks very much.