ADO Connection Timeout problem

前端 未结 2 1043
-上瘾入骨i
-上瘾入骨i 2021-01-22 21:50

Using TADOConnection class to connect to SQL server 2005 db.

Having ConnectionTimeOut := 5; // seconds.

Trying to open the connection synchronously.

When

2条回答
  •  温柔的废话
    2021-01-22 22:27

    No, it's enough to set the ConnectionTimeout property

    I've had the exact problem (D2009, MSSQL2005), but TADOConnection.ConnectionTimeout works fine for me (btw. the deafult value for this property is 15 seconds). Note, that the timeout dispersion is quite wide, so once you'll be timed out after 5 seconds and later on e.g. after 10 seconds, but 20 seconds is really too much for the connection attempt.

    Probably you have a problem with CommandTimeout (if you are trying to execute a query with the associated ADO data set component). You need to remember, that if you set TADOConnection.ConnectionTimeout := 5 and in your data set component e.g. TADOQuery.CommandTimeout := 15, and you're trying to execute query, then you will get timeout after 20 seconds.

    If you really have a problem with query execution, not only connection attempt, this post may help you ADO components CommandTimeout

提交回复
热议问题