Send feedback on this topic.
Teradata.Client.Provider
Database Property (TdConnection)
Example 



Teradata.Client.Provider Namespace > TdConnection Class : Database Property
Gets the default database name.
Syntax
'Declaration
 
Public Overrides NotOverridable ReadOnly Property Database As String
'Usage
 
Dim instance As TdConnection
Dim value As String
 
value = instance.Database
public override string Database {get;}
public:
property String^ Database {
   String^ get() override;
}

Property Value

The default database name or the default database name to be set once the connection (Teradata session) is opened. The default value is an empty string before a connection is opened.
Remarks
If the TdConnection is not open, this property returns the value specified in the TdConnection.ConnectionString or an empty string if the ConnectionString does not include a database attribute.

If the connection is open, this property returns an internally cached representation of last known default database. If the default database is changed via a TdConnection.ChangeDatabase method, a SQL DATABASE command is issued, an informational message (TdConnection.InfoMessage) is sent and the internally cached representation of last known default database is updated. TdConnection caches the last known default database to avoid additional roundtrips to the Advanced SQL Engine and back. We highly recommend setting the default database via the TdConnection.ConnectionString property. This will ensure that the last known default database is always correct for pooled connections.

Example
The following example creates an instance of TdConnection class, sets the Database property via the ConnectionString and opens a connection to Teradata.

public TdConnection CreateTdConnection()
{
    TdConnection cn = new TdConnection();
            
    cn.ConnectionString = 
       “Data Source=Teradata1;User Id=ab;Password=ab;Database=Retail;”;
            
    cn.Open();
            
    return cn;
}
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