I have run into a problem. It takes 30 seconds to connect to my MySQL server. I had set some brake point and found out that it was pausing at [conDatabase.Open();]. It does not just happen to me, so its not my internet. I have set the primary key in the database to what I am looking for. This is what I have,
Code:
try
{
MySqlConnection conDatabase = new MySqlConnection("Server=xxxxxxxx.com;Database=xxxxxxxx;Uid=xxxxxxxx;Pwd=xxxxxxxx;");
string statment = "SELECT * FROM users WHERE username =@user;";
MySqlCommand cmdDatabase = new MySqlCommand(statment, conDatabase);
cmdDatabase.Parameters.AddWithValue("@user", username);
MySqlDataAdapter da = new MySqlDataAdapter(cmdDatabase);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
conDatabase.Open(); //<-- 25 to 30sec!!
da.Fill(ds, "password");
dt = ds.Tables[0];
foreach (DataRow row in dt.Rows)
{
RetrunPassword = row["password"].ToString();
}
cmdDatabase.ExecuteNonQuery();
conDatabase.Close();
password = CalculateMD5Hash(username, password);
catch (Exception Errorz )
{
MessageBox.Show(Convert.ToString(Errorz ));
return false;
}
I know this is a 1/2 ass way of doing it, so I am thinking that is part of the problem.
Thanks for your help!