How to pass a timeout parameter to SQL Database Engine

I run a query that shuts down for the first two times and returns the results a third time.

How can I tell SQL Server to wait for the query to complete, rather than timing?

+3
source share
3 answers

By default, SqlCommand.CommandTimeout is set to 30 seconds. You can assign a longer duration before executing the request or set the value to 0 for no timeout. (if the question relates to .Net programming)

+5
source

You can also install it in the connection string in the connection string.
"Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=SSPI;Connection Timeout=30"

+1
source

- , . , .

, , .

, VBA ADODB - 60 :

Dim cn As ADODB.Connection
Set cn = new ADODB.Connection
cn.CommandTimeout = 60 

As Shane pointed out above, you can also set it in the connection string.

I think you can set it to 0, so it will never time out, but this is not recommended, because it means the server freezes or you lose the connection to the database, your application will wait forever.

+1
source

Source: https://habr.com/ru/post/1711129/


All Articles