c# mysql慢,在Mysql和C#中请求超时

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值