.NET code to load data from CSV to Progress database

Here’s a sample code in C# to write data from a CSV file to a Progress database using the System.Data.Odbc namespace

using System.Data.Odbc;

// Set up ODBC connection string
string connectionString = "Driver={Progress OpenEdge 11.7 Driver};HOST=<host>;PORT=<port>;DB=<database>;UID=<username>;PWD=<password>;";

// Set up SQL insert statement
string sqlInsert = "INSERT INTO <table> (col1, col2, col3) VALUES (?, ?, ?)";

// Open CSV file and read data
using (StreamReader streamReader = new StreamReader("<csv file path>"))
{
    // Set up ODBC command and connection
    using (OdbcConnection odbcConnection = new OdbcConnection(connectionString))
    using (OdbcCommand odbcCommand = new OdbcCommand(sqlInsert, odbcConnection))
    {
        // Open ODBC connection and begin transaction
        odbcConnection.Open();
        OdbcTransaction odbcTransaction = odbcConnection.BeginTransaction();
        odbcCommand.Transaction = odbcTransaction;

        // Loop through CSV rows and insert into Progress table
        while (!streamReader.EndOfStream)
        {
            string[] fields = streamReader.ReadLine().Split(',');
            odbcCommand.Parameters.Clear();
            odbcCommand.Parameters.AddWithValue("?", fields[0]);
            odbcCommand.Parameters.AddWithValue("?", fields[1]);
            odbcCommand.Parameters.AddWithValue("?", fields[2]);
            odbcCommand.ExecuteNonQuery();
        }

        // Commit transaction and close ODBC connection
        odbcTransaction.Commit();
        odbcConnection.Close();
    }
}

Note that you will need to replace <host>, <port>, <database>, <username>, <password>, <table>, and <csv file path> with your specific host, port, database, login credentials, table, and file path values, respectively. Additionally, you may need to modify the SQL insert statement and parameters to match your specific database schema.

Pamai Tech
Turning ideas into Reality

Products

Office Add-in

Enterprise Solutions

Cloud Consulting

UI UX Design

Data Transformation

Services

FAQ's

Privacy Policy

Terms & Condition

Team

Contact Us

Company

About Us

Services

Features

Our Pricing

Latest News

© 2025 Pamai Tech