Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ResetCommandTimeout Method

OdbcCommand.ResetCommandTimeout Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

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 OdbcCommand, 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 an SQL SELECT statement and a string to use to connect to the data source.

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

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

[C++] 
public:
    void CreateMyOdbcCommand(String* mySelectQuery, String* myConnectionString)
    {
        OdbcConnection* myConnection = new OdbcConnection(myConnectionString);
        OdbcCommand* myCommand = new OdbcCommand(mySelectQuery, myConnection);

        myCommand->CommandTimeout = 15;
        MessageBox::Show(String::Concat(S"Command timeout: ", __box(myCommand->CommandTimeout)));

        myCommand->ResetCommandTimeout();
        MessageBox::Show(String::Concat(S"Command timeout: ", __box(myCommand->CommandTimeout)));

    };

[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

OdbcCommand Class | OdbcCommand Members | System.Data.Odbc Namespace

Show:
© 2015 Microsoft