locked
Connection Timeout RRS feed

  • Question

  •  

    In one of my applications I want to set a connection timeout to 1 second when connecting to the SQL Server. .NET's SqlConnection already has connectiontimeout property as readonly and set to 15 seconds. So I cant use it. And if I use adodb.dll and its ADODB.Connection, this time I can set the objects connectiontimeout property. However, it just doesn't work. It still waits  along time even though I set the connectiontimeout to 1 second. The same goes when you try the same thing in Delphi.

    Anyone has any idea about this problem?

    Thursday, November 16, 2006 4:01 PM

Answers

  • How do you check and find "SqlConnection already has connectiontimeout property as readonly and set to 15 seconds"? From what I see in VS 2005, I can edit connectiontimeout property for sqlclient.

    Regarding why it still take a long time even if you set the timeout to 1 second, that's because the timeout property is enforced in different layer, specifically higer layer. If a connection is blocked or waiting in a API in lower level, it won't stop the connection until it  returns from lower level. If there is still time left, higher level may try to connect again. So, the timeout is not always enforced, you should not use it for precise timing.

     

    Thursday, November 16, 2006 6:31 PM

All replies

  • Do you want to change the timeout on the command or the connection ? Normally people want to specify the timeout on the command rather than on the connection.


    HTH, Jens K. Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---
    Thursday, November 16, 2006 4:17 PM
  • How do you check and find "SqlConnection already has connectiontimeout property as readonly and set to 15 seconds"? From what I see in VS 2005, I can edit connectiontimeout property for sqlclient.

    Regarding why it still take a long time even if you set the timeout to 1 second, that's because the timeout property is enforced in different layer, specifically higer layer. If a connection is blocked or waiting in a API in lower level, it won't stop the connection until it  returns from lower level. If there is still time left, higher level may try to connect again. So, the timeout is not always enforced, you should not use it for precise timing.

     

    Thursday, November 16, 2006 6:31 PM