.NET code to load data from Excel to Progress database

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

using System.Data.Odbc;
using System.Data.OleDb;

// 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 Excel file and read data
using (OleDbConnection oleDbConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=<excel file path>;Extended Properties='Excel 12.0 Xml;HDR=YES'"))
{
    using (OleDbCommand oleDbCommand = new OleDbCommand("SELECT * FROM [<worksheet name>$]", oleDbConnection))
    {
        oleDbConnection.Open();
        using (OleDbDataReader oleDbDataReader = oleDbCommand.ExecuteReader())
        {
            // 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 Excel rows and insert into Progress table
                while (oleDbDataReader.Read())
                {
                    odbcCommand.Parameters.Clear();
                    odbcCommand.Parameters.AddWithValue("?", oleDbDataReader.GetValue(0));
                    odbcCommand.Parameters.AddWithValue("?", oleDbDataReader.GetValue(1));
                    odbcCommand.Parameters.AddWithValue("?", oleDbDataReader.GetValue(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 <excel 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 and the Excel worksheet name to match your specific worksheet name.

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