2009年9月10日 星期四

SQL 2005 Connection timeout 連線逾時處理

DBA’s Quick Guide to Timeouts

by Chris Kempster
The author of: SQL Server 2000 for the Oracle DBA
Click here for more information, sample chapters, or to purchase this e-book.
The application development DBA needs a good understanding of the overarching application architecture and subsequent technologies (COM+, MSMQ, IIS, ASP etc) to more proactively debug and track down database performance problems. A good place to start is common timeout error. This article will provide a brief overview of where to look and how to set the values.

ADO

Within ADO, the developer can set:

connection timeout (default 15 seconds)
if the connection cannot be established within the timeframe specified
command timeout (default 30 seconds)
cancellation of the executing command for the connection if it does not respond within the specified time.

These properties also support a value of zero, representing an indefinite wait.

Here is some example code:

Dim MyConnection as ADODB.Connection

Set MyConnection = New ADODB.Connection

MyConnection.ConnectionTimeout = 30

MyConnection.Open

- and -

Set MyConnection = New ADODB.Connection

<>

MyConnection.Open strMyConn


Set myCommand = New ADODB.Command

Set myCommand.ActiveConnection = MyConnection

myCommand.CommandTimeout = 15

Take care with command timeouts are described by Microsoft:

http://support.microsoft.com/default.aspx?scid=KB;en-us;q188858

文件原文 http://vyaskn.tripod.com/watch_your_timeouts.htm

沒有留言: