Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

.Net Connection String with LDAP - response (3) by flash7gordon

$
0
0

I got a working teradata ldap connection to work with c# with the following:

  •  // 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++;

                    }

     


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>