Category: ASP

Connect to Sybase

Remember to install the Sybase OBBC drivers on the server.

using System.Data.Odbc;

OdbcConnection conn = new OdbcConnection();
            conn.ConnectionString = "Driver={SYBASE ASE ODBC Driver};NetworkAddress=HOSTNAME, PORT;DB=DBNAME;UID=USER;PWD=PASSWORD";
            conn.Open();

            OdbcCommand command = new OdbcCommand();
            command.Connection = conn;
            command.CommandText = "select distinct M_LABEL, M_NAME from TRN_CPDF_DBF";
            command.CommandType = CommandType.Text;
            OdbcDataReader reader = command.ExecuteReader();
            
             while (reader.Read())
             {
                 Console.WriteLine(reader.GetValue(0).ToString() + reader.GetValue(1).ToString());
             }


C#

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.