02-18-2021 07:39 AM
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?
02-22-2021 05:52 AM - edited 02-22-2021 05:53 AM
02-22-2021 06:39 AM
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.
02-23-2021 01:11 AM
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);
02-23-2021 03:08 AM
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;"