ADO Connection Timeout problem

前端 未结 2 1044
-上瘾入骨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

    0 讨论(0)
  • 2021-01-22 22:30

    TADOConnection.ConnectionTimeout - Timeout in milliseconds to connect to data source TADOConnection.CommandTimeout - Timeout in milliseconds to execute command

    if you getting timeout error on trying to connect, increase value of ConnectionTimeout property, else if you getting an error on executing some query, - increase value of CommandTimeout property.

    0 讨论(0)
提交回复
热议问题