IDbCommand.CommandTimeout 属性

定义

获取或设置在终止尝试执行命令并生成错误之前的等待时间(以秒为单位)。Gets or sets the wait time (in seconds) before terminating the attempt to execute a command and generating an error.

public:
 property int CommandTimeout { int get(); void set(int value); };
public int CommandTimeout { get; set; }
member this.CommandTimeout : int with get, set
Public Property CommandTimeout As Integer

属性值

等待命令执行的时间(秒)。The time (in seconds) to wait for the command to execute. 默认值为 30 秒。The default value is 30 seconds.

异常

分配的属性值小于 0。The property value assigned is less than 0.

示例

下面的示例创建派生类的实例,SqlCommand 并设置其一些属性。The following example creates an instance of a derived class, SqlCommand and sets some of its properties.

public void CreateSqlCommand() 
{
   SqlCommand command = new SqlCommand();
   command.CommandTimeout = 15;
   command.CommandType = CommandType.Text;
}
Public Sub CreateSqlCommand()
    Dim command As New SqlCommand()
    command.CommandTimeout = 15
    command.CommandType = CommandType.Text
End Sub

适用于

另请参阅