SqlCommand.ResetCommandTimeout Method
Resets the CommandTimeout property to its default value.
[Visual Basic] Public Sub ResetCommandTimeout() [C#] public void ResetCommandTimeout(); [C++] public: void ResetCommandTimeout(); [JScript] public function ResetCommandTimeout();
Remarks
The default value of the CommandTimeout is 30 seconds.
Example
[Visual Basic, C#, C++] The following example creates a 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 a SQL Select statement and a string to use to connect to the data source.
[Visual Basic] Public Sub CreateMySqlCommand(mySelectQuery As String, myConnection As SqlConnection) Dim myCommand As New SqlCommand(mySelectQuery, myConnection) myCommand.CommandTimeout = 15 MessageBox.Show(myCommand.CommandTimeout.ToString()) myCommand.ResetCommandTimeout() MessageBox.Show(myCommand.CommandTimeout.ToString()) End Sub 'CreateMySqlCommand [C#] public void CreateMySqlCommand(string mySelectQuery, SqlConnection myConnection) { SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection); myCommand.CommandTimeout = 15; MessageBox.Show(myCommand.CommandTimeout.ToString()); myCommand.ResetCommandTimeout(); MessageBox.Show(myCommand.CommandTimeout.ToString()); } [C++] public: void CreateMySqlCommand(String* mySelectQuery, SqlConnection* myConnection) { SqlCommand* myCommand = new SqlCommand(mySelectQuery, myConnection); myCommand->CommandTimeout = 15; MessageBox::Show(myCommand->CommandTimeout.ToString()); myCommand->ResetCommandTimeout(); MessageBox::Show(myCommand->CommandTimeout.ToString()); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
SqlCommand Class | SqlCommand Members | System.Data.SqlClient Namespace