Export (0) Print
Expand All

OleDbCommand.ResetCommandTimeout Method

Resets the CommandTimeout property to the 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 an OleDbCommand, sets the CommandTimeout, displays the property, resets the CommandTimeout, and displays the property again. To accomplish this, the method is passed a string that is a SQL Select statement and a string to use to connect to the data source.

[Visual Basic] 
Public Sub CreateMyOleDbCommand(mySelectQuery As String, _
myConnectionString As String)
    Dim myConnection As New OleDbConnection(myConnectionString)
    Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)
    myCommand.CommandTimeout = 15
    MessageBox.Show(myCommand.CommandTimeout.ToString())
    myCommand.ResetCommandTimeout()
    MessageBox.Show(myCommand.CommandTimeout.ToString())
End Sub

[C#] 
public void CreateMyOleDbCommand(string mySelectQuery, string myConnectionString) 
{
   OleDbConnection myConnection = new OleDbConnection(myConnectionString);
   OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
   myCommand.CommandTimeout = 15;
   MessageBox.Show(myCommand.CommandTimeout.ToString());
   myCommand.ResetCommandTimeout();
   MessageBox.Show(myCommand.CommandTimeout.ToString());
}

[C++] 
public:
 void CreateMyOleDbCommand(String* mySelectQuery, String* myConnectionString) 
 {
    OleDbConnection* myConnection = new OleDbConnection(myConnectionString);
    OleDbCommand* myCommand = new OleDbCommand(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 Language Filter 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

See Also

OleDbCommand Class | OleDbCommand Members | System.Data.OleDb Namespace

Show:
© 2015 Microsoft