I didn't encounter this error when my database was offline. I have just made my database online with db4free.net.
Everytime I log in this error occurs. Can somebody point out what's wrong?
private void btnLogIn_Click(object sender, EventArgs e)
{
string query = "select * from tbl_accounts where username='" + tbxUsername.Text + "' and password='" + tbxPassword.Text + "'";
MySqlCommand command = new MySqlCommand(query, connection);
MySqlDataAdapter da = new MySqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
try
{
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
if (dt.Rows.Count > 0)
{
employee_id = (dr["employee_id"].ToString().PadLeft(4, '0'));
fullname = (dr["account_firstname"] + " " + dr["account_lastname"]).ToString();
this.Invoke(new Action(() =>
{
connection.Open();
command.ExecuteNonQuery();
connection.Close();
this.Close();
th = new Thread(openNewForm);
th.SetApartmentState(ApartmentState.STA);
th.Start();
}));
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Here is the error:
Updated: Here is my connection string:
MySqlConnection connection = new MySqlConnection("datasource=db4free.net;Convert Zero Datetime=True;SslMode=none");