简体   繁体   中英

Connect Timeout does not work

I have a report query and it takes more than 15 seconds (default value for timeout) to run. I added 'Connect Timeout' parameter to my connection string in web.config but it did not make any difference. The query still times out in 15 seconds.

connectionString="server=xx.xx.xx.xx;database=yyy;User Id=zzz;Password=vvv; Connect Timeout=60 " providerName="System.Data.SqlClient"

Any suggestion?

PS: I am using SqlCommand object to run the query.

That's the timeout for establishing a connection , not executing a query. You can set the command timeout using the CommandTimeout property on the SqlCommand object.

To what i see is that you are missing a semicolon over your paramter.

connectionString="server=xx.xx.xx.xx;database=yyy;User Id=zzz;Password=vvv;Connect Timeout=60"; providerName="System.Data.SqlClient"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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