CommandTimeout triggered when you have long requests. There is a CommandTimeout TADOConnection property, but this does not work. Instead, you should use CommandTimeout TADODataSet .
If the server is unavailable, your question says "connection is lost", you need to specify the ConnectionTimeout of the TADOConnection component. The default is 15 seconds before the control is returned to your application.
Edit 1 I think I discovered a situation where CommandTimeout is not working. I checked this against a really big table. It takes a few minutes to return all rows. If my stored procedure does select * from BigTable , the request timeout will never happen. At least I was not patient enough to wait. But if the query looks like this: select * from BigTable order by Col1 and Col1 no Col1 index, CommandTimout works as expected.
The difference between the two requests is obvious when you run them in SSMS. The first begins to return the rows immediately, and the second must โthinkโ about it before it returns the rows. When SQL Server found the rows it needed and started returning them, CommandTimeout does not work.
If you set CursorLocation to clUseServer , then CommandTimeout will work as expected for both requests.
Mikael eriksson
source share