Here’s a sample code in C# using the .NET framework to write data to a Progress database
using System; using System.Data; using System.Data.Odbc; namespace ProgressDatabaseWriterExample { 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 insert data into the Progress database string sql = "INSERT INTO Customer (CustomerID, CustomerName, Address, City, State, Zip) VALUES (?, ?, ?, ?, ?, ?)"; // Define the parameter values for the SQL statement string customerID = "12345"; string customerName = "Acme Inc."; string address = "123 Main St"; string city = "Anytown"; string state = "CA"; string zip = "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 values for the SQL statement command.Parameters.AddWithValue("@CustomerID", customerID); command.Parameters.AddWithValue("@CustomerName", customerName); command.Parameters.AddWithValue("@Address", address); command.Parameters.AddWithValue("@City", city); command.Parameters.AddWithValue("@State", state); command.Parameters.AddWithValue("@Zip", zip); // Execute the SQL statement to insert data into the Progress database int rowsAffected = command.ExecuteNonQuery(); Console.WriteLine("{0} row(s) affected.", rowsAffected); } } Console.WriteLine("Data has been written to the Progress database."); Console.ReadLine(); } } }
In this example, the Odbc library is used to write data to 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 insert data into the Progress database. The AddWithValue
method of the OdbcParameterCollection
object is used to define the parameter values for the SQL statement. Finally, the ExecuteNonQuery
method of the OdbcCommand
object is used to execute the SQL statement and write data to the Progress database.