Here’s a sample code in C# using the .NET framework to read data from a Progress database
using System; using System.Data; using System.Data.Odbc; namespace ProgressDatabaseReaderExample { class Program { static void Main(string[] args) { // Define the connection string for the Progress database string connectionString = "DSN=ProgressDSN;UID=Username;PWD=Password;"; // Define the SQL statement to select data from the Progress database string sql = "SELECT * FROM Customer WHERE CustomerID = ?"; // Define the parameter value for the SQL statement string customerID = "12345"; // Create a new instance of the OdbcConnection class using (OdbcConnection connection = new OdbcConnection(connectionString)) { // Open the connection to the Progress database connection.Open(); // Create a new instance of the OdbcCommand class using (OdbcCommand command = new OdbcCommand(sql, connection)) { // Define the parameter value for the SQL statement command.Parameters.AddWithValue("@CustomerID", customerID); // Create a new instance of the OdbcDataAdapter class using (OdbcDataAdapter adapter = new OdbcDataAdapter(command)) { // Create a new instance of the DataTable class DataTable dataTable = new DataTable(); // Fill the DataTable with the data from the Progress database adapter.Fill(dataTable); // Loop through each row in the DataTable foreach (DataRow row in dataTable.Rows) { // Print the data to the console Console.WriteLine("{0} {1} {2} {3} {4} {5}", row["CustomerID"], row["CustomerName"], row["Address"], row["City"], row["State"], row["Zip"]); } } } } Console.WriteLine("Data has been read from the Progress database."); Console.ReadLine(); } } }
In this example, the Odbc library is used to read data from a Progress database. The OdbcConnection
class is used to create a new instance of the ODBC connection to the Progress database. The Open
method of the OdbcConnection
object is used to open the connection. The OdbcCommand
class is used to create a new instance of the SQL command to select data from the Progress database. The AddWithValue
method of the OdbcParameterCollection
object is used to define the parameter value for the SQL statement. The OdbcDataAdapter
class is used to create a new instance of the data adapter to fill a DataTable
object with the data from the Progress database. Finally, the data in the DataTable
object is printed to the console.