// below has to be downloaded and "References"d in the project
using Teradata.Client.Provider;
using (TdConnection cn = new TdConnection())
{
TdConnectionStringBuilder conStrBuilder = new TdConnectionStringBuilder();
// i got the server from the ldap odbc description of the connection
conStrBuilder.DataSource = "tdserver.com";
conStrBuilder.Database = "mydb";
conStrBuilder.UserId = "myuid";
conStrBuilder.Password = "mypw";
conStrBuilder.AuthenticationMechanism = "LDAP";
Console.WriteLine("conn string was: " + conStrBuilder.ConnectionString);
cn.ConnectionString = conStrBuilder.ConnectionString; cn.Open();
TdCommand cmd = cn.CreateCommand();
cmd.CommandText = "select top 100 * from mydb.mytable";
TdDataReader reader = cmd.ExecuteReader();
Console.WriteLine("{0} records affected.", reader.RecordsAffected);
int currentRow = 1;
while (reader.Read())
{
for (int columnIndex = 0; columnIndex < reader.FieldCount; columnIndex++)
{
// this is pretty cool. Does every field with it's name.
Console.WriteLine("Row [{0,4}] [{1,20}] = {2}",
currentRow, reader.GetName(columnIndex),
reader.GetValue(columnIndex));
}
Console.WriteLine();
currentRow++;
}
I got a working teradata ldap connection to work with c# with the following:
using Teradata.Client.Provider;
using (TdConnection cn = new TdConnection())
{
TdConnectionStringBuilder conStrBuilder = new TdConnectionStringBuilder();
// i got the server from the ldap odbc description of the connection
conStrBuilder.DataSource = "tdserver.com";
conStrBuilder.Database = "mydb";
conStrBuilder.UserId = "myuid";
conStrBuilder.Password = "mypw";
conStrBuilder.AuthenticationMechanism = "LDAP";
Console.WriteLine("conn string was: " + conStrBuilder.ConnectionString);
cn.ConnectionString = conStrBuilder.ConnectionString; cn.Open();
TdCommand cmd = cn.CreateCommand();
cmd.CommandText = "select top 100 * from mydb.mytable";
TdDataReader reader = cmd.ExecuteReader();
Console.WriteLine("{0} records affected.", reader.RecordsAffected);
int currentRow = 1;
while (reader.Read())
{
for (int columnIndex = 0; columnIndex < reader.FieldCount; columnIndex++)
{
// this is pretty cool. Does every field with it's name.
Console.WriteLine("Row [{0,4}] [{1,20}] = {2}",
currentRow, reader.GetName(columnIndex),
reader.GetValue(columnIndex));
}
Console.WriteLine();
currentRow++;
}