Working with C# and MySQL here (Visual Studio 12 and MySQL workbench 6.1).
This is what I have so far.
string strCheck = "SHOW TABLES LIKE \'emp\'";
MySqlCommand cmd = new MySqlCommand(strCheck, con);
cmd.Prepare();
if (cmd.ExecuteNonQuery() > 0)
{
Console.WriteLine("exists");
}
else
{
Console.WriteLine("does not");
}
I have seen many questions here (mostly related to PHP) but they don't seem to be working for me. Also, I don't want a solution where we check if the table has any rows, because the table can be empty, and what I want to know is whether it exists.
Thanks.