Hello there,
I''ve developed a windows application which uses internet based MySQL database.
I''m connecting to the server and directly executing commands..But most of the time it''s getting timed-out...Here is my 1 part of code in which always showing exception timeout...What''s the solution to it???cmd = connection.CreateCommand();
string qyery = "select * from employee_details inner join employee_status on employee_details.Employee_Id=employee_status.Emp_Id where employee_status.Emp_Branch_Id=@Emp_Branch_Id and not employee_details.Emp_Type=''BM'' and not employee_status.Emp_Acc_Stat=''DELETED'' ";//get the employee account status and emp information simultaneously in the branch of BM
cmd.Parameters.AddWithValue("@Emp_Branch_Id", home.empBranchId);
cmd.CommandText = qyery;
da.SelectCommand = cmd;
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
ds.Clear();
int m=da.Fill(ds, "Employee_details");
This one is working perfectly.....
dbconnector = new DataConnector();
conn = new MySqlConnection();
conn = dbconnector.connect();
MySqlCommand cmd = new MySqlCommand();
cmd = conn.CreateCommand();
string query = "select * from customer_details";
cmd.CommandText = query;
try
{
da.SelectCommand = cmd;
MySqlCommandBuilder cb = new MySqlCommandBuilder(da);
da.Fill(ds, "customer_details");
MessageBox.Show("filled customer details to dataset ");
DataGridView1.DataSource = ds.Tables["customer_details"];
conn.Close();
generatedException = false;
}
catch (MySqlException ex)
{
MessageBox.Show("Generated Exception=" + ex.ToString());
generatedException = true;
}
Thanx
解决方案If the connection is established and there is no issue there, it could just be taking too long to retrieve the data from the query. I am assuming this is the problem because the complexity of your failing query is much higher than your working query. Do you have the ability to create indexes on the database? If not you may need to rethink your query or set the timeout higher.