System.Data Namespace IDbCommand Class
Sets or retrieves the wait time before terminating the attempt to execute a command and generating an error.
Script |
IDbCommand.CommandTimeout [ = intTimeout ] |
intTimeout |
The time ( in seconds ) to wait for the command to execute. |
The property is read/write with a default value of 30.
Exception Type |
Condition |
ArgumentException |
The property value assigned is less than 0. |
A value of 0 indicates no limit, and should be avoided in a CommandTimeout because an attempt to execute a command will wait indefinitely.
The following example creates an instance of the derived SqlCommand class, and sets some of its properties.
void setSqlCommand ( ) {
SqlCommand myCmd = new SqlCommand ( );
myCmd.CommandText = "SELECT * FROM Categories ORDER BY CategoryID";
myCmd.CommandTimeout = 15;
}
Public Sub setSqlCommand ( )
Dim myCmd As New SqlCommand ( )
myCmd.CommandText = "SELECT * FROM Categories ORDER BY CategoryID"
myCmd.CommandTimeout = 15
End Sub |
|
C# |
VB |
IDbCommand Members CommandText Connection CommandType