TdConnection class represents a connection or session to Teradata. It is used to specify the session characteristics such as Session Character Set or User Id when including a
TdConnection.ConnectionString in the constructor.
The following example creates a TdConnection class and opens a session to Teradata. The "Show Table Customers" SQL statement is executed and the result is assigned to the customers variable.
class Example
{
static void Main(String[] args)
{
TdConnection cn = null;
try
{
cn = new TdConnection("Data Source=Teradata1;User Id=ab;Password=ab;");
cn.Open();
TdCommand cmd = new TdCommand("Show Table Customers", cn);
String customers = (String) cmd.ExecuteScalar();
cmd.Dispose();
}
catch(TdException e)
{
Debug.WriteLine(e.Message);
}
finally
{
if (null != cn)
{
cn.Close();
}
}
}
}
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019