I am connecting to MySQL database in C#. I am using 100 percent correct user name and password but I get invalid username/password or error no 1045. I have tried deleting the database and users and recreated all these and assigned all permissions in cpanel but failed. It works on my computer localhost(virtual server). Tried so many times. please help. My code is
string myConnectionString = @"server=mydomain.co.uk;userid=MyUserID;
password=PasswordOfUser;database=databasename";
MySqlConnection conn = null;
try
{
//MySqlConnection
conn = new MySqlConnection(myConnectionString);
conn.Open();
MessageBox.Show("OK");
conn.Close();
}
catch (MySqlException ex)
{
switch (ex.Number)
{
case 0:
MessageBox.Show("Cannot connect to server. Contact administrator");
break;
case 1042:
MessageBox.Show("Can't get hostname address. Check your internet connection. If does not solve, contact Administrator");
break;
case 1045:
MessageBox.Show("Invalid username/password");
break;
}
}