LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Toolkit 2.2 - MS SQL Server - How to set connection timeout?

Hello,

 

I use SQL Toolkit 2.2 to connect to a database in a Microsot SQL Server 2014.

 

I use this connection string and it works:

"Provider=SQLOLEDB.1;Password=%s;Persist Security Info=True;User ID=%s;Initial Catalog=%s;Data Source=%s"

 

I try to add "Connection Timeout = 5;" to the connection string but the connection timeout remains 30 seconds.

 

Anyone have any ideas on how to change the connection timeout?

 
0 Kudos
Message 1 of 5
(23,370 Views)
Using SQL Server Management Studio
  1. In Object Explorer, right-click a server and select Properties.
  2. Click the Connections node.
  3. Under Remote server connections, in the Remote query timeout box, type or select a value from 0 through 2,147,483,647 to set the maximum number seconds for SQL Server to wait before timing out.

Great Lakes Login

0 Kudos
Message 2 of 5
(23,319 Views)

Hi AngelesCanis,

 

I can't modify the server properties because my application connects to the customer's SQL server.

 

In any case, the connection timeout information should be from the client. It is not so?

 

My goal is to decrease the connection timeout to avoid waiting 30 seconds in case the server is unreachable.

 

 

 
0 Kudos
Message 3 of 5
(23,309 Views)

Connection timeout can be set to 5" in the connection string with "Connect Timeout = 5;" (not "Connection Timeout = 5;" as you wrote.

Based on my experiecne this works as expected and it's the timeout while trying to create the connection.

 

If you're interested in "command timeout" (i.e. the time to wait for a command to execute) you have to use

DBSetStatementAttribute (hstmt, ATTR_DB_STMT_COMMAND_TIMEOUT, 5);

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 4 of 5
(23,297 Views)

Thanks Vix.

 

I also try with the string Connect Timeout = 5;  but the timeout is still 30 seconds. Is it possible that there are problems with the versions? I use CVI 2012 and SQL toolkit 2.2.

 


This is the complete connection string:

"Provider=SQLOLEDB.1;Password=%s;Persist Security Info=True;User ID=%s;Initial Catalog=%s;Data Source=%s;Connect Timeout = 5;"

0 Kudos
Message 5 of 5
(23,294 Views)