i have the following query
SELECT count( * ) COLUMN_NAME FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'ptbs.ms_karyawan'
and execute them on mysql wamp, it returns 2 columns
but then, when i execute the query above using C#, it returns -1 columns, here is the code
private void button1_Click(object sender, EventArgs e)
{
int table = dbc.Count("ptbs.ms_karyawan");
msg.Sukses("Jumlah table adalah :"+table, "Login");
}
and here is the dbc.count()
code
public int Count(string table_name)
{
string query = "SELECT count( * ) COLUMN_NAME FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '"+table_name+"'";
int table = 0;
if (OpenConnection() == true)
{
//create mysql command
MySqlCommand cmd = new MySqlCommand();
//Assign the query using CommandText
cmd.CommandText = query;
//Assign the connection using Connection
cmd.Connection = connection;
//Execute query
table = cmd.ExecuteNonQuery();
//close connection
this.CloseConnection();
}
return table;
}
why did they return different value, though i'm using the same query ? what did i do wrong ?