Send feedback on this topic.
Close Method (TdConnection)

Teradata.Client.Provider Namespace > TdConnection Class : Close Method
Closes the connection to Teradata.
Public Overrides NotOverridable Sub Close() 
Dim instance As TdConnection
public override void Close()
void Close(); override 

If the connection is in closed state, the method simply returns. However, if the connection is open, the Close method either disconnects (logs off) from Teradata or returns the Teradata session back to the pool. In either case, any active explicit transaction is rolled back by Teradata or the .NET Data Provider for Teradata. See TdConnection.StateChange event for additional information about events generated by the Close method.

Before calling Close, it is important that the command object is closed (TdCommand.Dispose) first before closing the connection to Teradata. However, if the Close is called before the command object is closed, the provider will perform the following actions:

With the introduction of Redrive and Recoverable Network Protocol, the TdConnection.Close may be used to cancel a reconnection that may not be completed.

If the TdConnection.State is Connecting while TdConnection.Close is executed, the reconnection will be scheduled for cancellation. During reconnection the acknowledgement of the TdConnection.Close may be delayed a maximum of period of time defined in TdConnectionStringBuilder.RecoveryMaximumInterval.

The following example creates a TdConnection class and illustrates the use of Open and Close methods:

public Boolean TestConnectivity(String connectionString)
    Boolean connectivity = false;
    TdConnection cn = new  TdConnection(connectionString);
       connectivity = true;
    catch(Exception e)
       connectivity = false;
    return connectivity;	

Target Platforms: Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2

See Also


TdConnection Class
TdConnection Members