Did this article resolve your question/issue?



C# Sample Code to connect a Progress Database

« Go Back


TitleC# Sample Code to connect a Progress Database
URL NameP107401
Article Number000127014
EnvironmentProduct: Progress
Version: 9.1x
Product: OpenEdge
Version: 10.1x, 11.x
OS: Windows
Other: ODBC, C#
Question/Problem Description
C# sample code to connect a Progress Database

How to connect to an OpenEdge database from a C# program
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
The following sample code written in C# shows how to connect to a Progress OpenEdge database from a program written in C# through an ODBC DSN:
using System;
using System.Data;
using System.Data.Odbc;
public class TestConnect
   public static void Main(string[] args)
      //The connection string assumes there is a DSN named sports for a Progress database.
      //Alternatively, a DSN-less connection string could be used in its place. See article# 000022406 for more details.

      string connectionString =  "DSN=sports;" +
                                 "UID=sysprogress;" +
      IDbConnection dbconn;
      dbconn = new OdbcConnection(connectionString);
      IDbCommand dbcmd = dbconn.CreateCommand();
      string sqlstr =   "SELECT country,name FROM pub.customer";
      dbcmd.CommandText = sqlstr;
      IDataReader reader = dbcmd.ExecuteReader();
      while(reader.Read()) {
           string country = (string) reader["country"];
           string name = (string) reader["name"];
           Console.WriteLine("Customer : " + name  +  " country is: " + country );
      reader = null;
      dbcmd = null;
      dbconn = null;
Last Modified Date11/20/2020 7:37 AM
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.