Answer the question
In order to leave comments, you need to log in
Why can't connect to MySql database?
Hey!
I'm trying to connect to the database, but I'm getting the following error -
and the same error is also displayed in this line
*****
adapter.Fill(table);
*****
private void connecting_Click(object sender, EventArgs e)
{
string userLogin = userName.Text;
string pass= Pass.Text;
int hash = Convert.ToInt32(Hash.Text);
baseUsers db = new baseUsers();
DataTable table = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter();
MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE 'name' = @uL AND 'pass' = @uK AND 'hash' = @uH", db.GetConnection());
command.Parameters.Add("uL", MySqlDbType.VarChar).Value = userLogin;
command.Parameters.Add("uK", MySqlDbType.VarChar).Value = pass;
command.Parameters.Add("uH", MySqlDbType.Int32).Value = hash;
adapter.SelectCommand = command;
adapter.Fill(table);
if (table.Rows.Count > 0)
{
MessageBox.Show("user [true]", "INFO");
}
else
{
MessageBox.Show("user [false]", "INFO");
}
}
Answer the question
In order to leave comments, you need to log in
Try to connect through MySql Workbench first,
or check access with the powershell command
Test-NetConnection 77.222.40.101 -Port 5431
. If the connection fails, then the hosting most likely has a firewall that blocks access from unfamiliar IPs. This is useful if you're leaking all connection data to the network, as you've done now.
(Do not do this in the future and change the password)
If there is a firewall, then you need to add your public IP to the exceptions
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question