Q:

Count rows and columns query in Visual Studio C#

How to count rows and columns in a MySql database from Visual Studio C#?
I want to use the number of columns, and the number of rows as integers.
conn.Open();
private MySqlCommand cmd = new MySqlCommand("SELECT COUNT(*) FROM DT_RSSI_VALUES_GRID_" + gridDesc + ";", conn);
int x = cmd.ExecuteReader();

I'm getting the following error:

Error 13  Cannot implicitly convert type
  'MySql.Data.MySqlClient.MySqlDataReader' to 'int'

A:

You are going to want to use ExecuteScalar which returns a single value, like:
int x = cmd.ExecuteScalar();

