简体   繁体   中英

Error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding

The environments I'm using are: .NET (2.0) and SQL Server 2005.

The scenario: in a .NET form the user gets prompted for two variables that will be provided to a stored procedure in SQL Server. Once the records are returned from the stored procedure, the .NET app will import these records to a .csv file.

The trick here is that the stored procedure is dynamic. The records returned are not always the same columns or populating the same temp table. The .NET app works when the stored procedure runs in less than 30 secs.

I have increase my conn.CommandTimeout = 6000 in my app and I have increase the "remote query connection" in SQL Server to 6000 as well but it's still failing for those variables running longer then 30 secs.

Any suggestions is greatly appreciated.

Thanks Chaydee

This could be because you are setting the command timeout on the connection instead of the command object itself. Can't see your code but if you are using a DataReader, DataAdapter etc. try setting CommandTimeout on those objects. A few other possibilities:

  1. the connection timeout is being exceeded before the query is being run. Not likely, but still, what is the connection timeout? It should be >= any CommandTimeout.
  2. the CommandTimeout call is not being executed.
  3. something else is later overriding the CommandTimeout call.

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