且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySqlException:超时已过期-增加连接超时无效

更新时间:2023-10-18 20:31:40

我以前遇到过此问题. ConnectTimeout属性仅适用于连接到数据库时发生的超时,不适用于查询.

I've had this problem before. ConnectTimeout property only applies to time outs that occur when connecting to the database, not for queries.

CommandTimeout 但是指定等待查询返回的时间.我相信默认值为30秒.仔细检查您的MySql库的文档,但是对于SqlCommand,CommandTimeout的单位是秒,而不是毫秒.

CommandTimeout however specifies how long it should wait for the query to return. I believe the default is 30 seconds. Double check the documentation for your MySql library, but for SqlCommand the CommandTimeout is in Seconds not milliseconds.