[C# n MySQL] Creating a database using Connector/NET Programming?
- by yeeen
How to create a database using connector/net programming? How come the following doesn't work?
string connStr = "server=localhost;user=root;port=3306;password=mysql;";
MySqlConnection conn = new MySqlConnection(connStr);
MySqlCommand cmd;
string s0;
try
{
conn.Open();
s0 = "CREATE DATABASE IF NOT EXISTS `hello`;";
cmd = new MySqlCommand(s0, conn);
conn.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}