2
Good evening, I’m having trouble with the following context:
MySql
Using the line of code below I tried to connect to a remote mysql server to try to access some tables and comes the following error:
Since I have tried everything and so far I have not achieved any result with the code below:
public bool IsLogged;
public string username;
public string UAC_L;
public int id;
MySqlConnection myconnection;
MySqlConnectionStringBuilder conn;
conn = new MySqlConnectionStringBuilder();
conn.Server = "mysql2.000webhost.com";
conn.UserID = "a1478344_app";
conn.Password = "SENHA!";
conn.Port = 3306;
myconnection = new MySqlConnection(conn.ToString());
myconnection.Open(); // O Erro ocorre aqui!
#region !OBFUSCATED!
MySqlCommand command_login = myconnection.CreateCommand();
command_login.CommandText = "SELECT usr_id,usr_rname,usr_UASC FROM `a1478344_app`.`app_users` WHERE usr_email=`@email` AND usr_password=`@senha`"
command_login.Parameters.AddWithValue("@email", email_t.Text);
command_login.Parameters.AddWithValue("@senha", Base64.Base64Encode(senha_t.Text));
MySqlDataReader reader = command_login.ExecuteReader();
if (reader.Read())
{
id = reader.GetInt32("usr_id");
username = reader.GetString("usr_rname");
UAC_L = reader.GetString("usr_UASC");
MessageBox.Show(string.Format("O Usuário {0} tem o ID {1} com privilégios de {2}", username, id, UAC_L));
myconnection.Close();
}
#endregion
The error happens when after I enter the data from ConnectionString
and apply the method myconnection.Open();
And the code of that error is one such 1042
as per Mysqlexception.Number.
Solution Explorer with the references used.
Are you sure the database connection information is correct? I ask only to exclude this hypothesis :)
– Dherik
Yes they are! I checked and everything! but in the same way it is this error!
– FRNathan13
A doubt the explorer Solution is right?
– FRNathan13
You have checked if you can actually connect manually to the server
mysql2.000webhost.com
? I mean, even if your credentials are correct, there could be some problem connecting your machine to the server.– Dherik
yes it is the mysql server of 000webhost
– FRNathan13