System.Data.SqlClient Namespace SqlCommand Class
Resets the CommandTimeout property to its default value.
[ VB ]
Public Sub ResetCommandTimeout ( )
[ C# ]
public void ResetCommandTimeout ( );
[ C++ ]
public: void ResetCommandTimeout ( );
[ JScript ]
public function ResetCommandTimeout ( );
The default value of the CommandTimeout is 30 seconds.
The following example initializes an SqlCommand, sets the CommandTimeout, displays the property,resets the CommandTimeout, and displays the property again. In the example, the application passes a string that is an SQL Select statement and a string to use to connect to the data source.
void setSqlCommand ( string query, SqlConnection myConn ) {
SqlCommand myCommand = new SqlCommand ( query, myConn );
myCommand.CommandTimeout = 15;
Response.Write ( myCommand.CommandTimeout.ToString ( ) );
myCommand.ResetCommandTimeout ( );
Response.Write ( myCommand.CommandTimeout.ToString ( ) );
}
Public Sub setSqlCommand ( query As String, myConn As SqlConnection )
Dim myCommand As New SqlCommand ( query, myConn )
myCommand.CommandTimeout = 15
Response.Write ( myCommand.CommandTimeout.ToString ( ) )
myCommand.ResetCommandTimeout ( )
Response.Write ( myCommand.CommandTimeout.ToString ( ) )
End Sub |
|
C# |
VB |
SqlCommand Members