Send feedback on this topic.
Teradata.Client.Provider
Open Method
Example 



Teradata.Client.Provider Namespace > TdConnection Class : Open Method
Opens a Teradata session using the attributes specified via the TdConnection.ConnectionString.
Syntax
'Declaration
 
Public Overrides NotOverridable Sub Open() 
'Usage
 
Dim instance As TdConnection
 
instance.Open()
public override void Open()
public:
void Open(); override 
Exceptions
ExceptionDescription
The TdConnection is disposed.
TdConnection is not in the Closed state.
The Advanced SQL Engine returned an error or the .NET Data Provider for Teradata returned an error.
Remarks

If connection pooling is turned off, TdConnection attempts to establish a new Teradata session. Otherwise, the ConnectionPool either returns an existing Teradata Session or creates a new Teradata session if the number of pooled sessions is less than Max Pooled Size.

If the connection string has a Database attribute, the TdConnection.ChangeDatabase method is called immediately after a session is opened to Teradata. This will result in additional roundtrips to the Advanced SQL Engine. We strongly recommend that you modify the User (See Teradata manual for information on Create User or Alter User) and add a default database. This will enhance the overall performance of opening a connection to the Advanced SQL Engine. Please note that ChangeDatabase method is called independently of whether the connection pooling is turned on or off and errors generated as a result of an invalid supplied ConnectionString Database attribute are ignored.

If the password has expired and pooling is turned off, then an TdConnection.InfoMessage event is triggered. The application should respond to the event by:

1) Change the password
2) Close the TdConnection
3) Open the TdConnection

Alternatively, the application can set the ‘New Password’ attribute in the connection string.

Example
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);
            	
   try
   {
      cn.Open();
      connectivity = true;
   }
   catch(Exception e)
   {
      connectivity = false;
   }
            
   cn.Close();
   return connectivity;
}
Requirements

Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019

See Also

Reference

TdConnection Class
TdConnection Members