简体   繁体   English

30秒后连接超时

[英]Connection timeout after 30 seconds

I have a C# program connecting to a MYSQL database. 我有一个C#程序连接到MYSQL数据库。 The stored procedure takes longer than 30 seconds so the connection times out. 存储过程需要30秒钟以上,因此连接超时。 What I'm looking to do is to increase the alloted time to do the stored procedure to 5 minutes. 我想要做的是将分配给存储过程的时间增加到5分钟。 I know that the default time out is 30 seconds and need to increase the alloted time. 我知道默认超时为30秒,需要增加分配的时间。 Is it possible to do this in C# or do I need to perform less stored procedures? 是否可以在C#中执行此操作,或者我需要执行更少的存储过程?

您还可以使用Connect Timeout property在字符串连接中配置Connect Timeout property

Config File : "Data Source=;Initial Catalog=;Connect Timeout=...."

Where you create your sql query command: 在哪里创建sql查询命令:

command.CommandTimeout = int.MaxValue;

or set int.MaxValue to the timeout of your choice. 或将int.MaxValue设置为您选择的超时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM