Connecting to progress OpenEdge Db from .net using ODBC

Posted by brip22 on 02-Mar-2013 14:59

Hi i installed the trial version in my pc and just wanted to have a quick app that was able to read from the database. but still i get errors connecting and i am unable to query the databse. could someone please hlpe me out? i dont know if the trial version will give you issues when connecting using ODBC, or if i am using wrong paramenters when buidling the connection string. Where do i find the port DSN... and the rest of the info to create connection string?

thanks

Brian

c# code

public static string GetODBCDriverName(string Database, string Version)

{

string ODBCDriverName = "";

RegistryKey registryKey = Registry.LocalMachine;

RegistryKey registrySubKey = registryKey.OpenSubKey(@"SOFTWARE\ODBC\ODBCINST.INI\");

String[] SubKeyNames = registrySubKey.GetSubKeyNames();

foreach (String KeyName in SubKeyNames){

if (KeyName.Contains(Database) && KeyName.Contains(Version)){

ODBCDriverName = KeyName;

break;

}}

registrySubKey.Close();

registryKey.Close();

return ODBCDriverName;

}

then

using the following code to connect to the database

OdbcConnectionStringBuilder odbcConnectionStringBuilder = new OdbcConnectionStringBuilder();

OdbcCommand odbcCommand;

int RecordFound = 0;

odbcConnectionStringBuilder.Driver = GetODBCDriverName("Progress", "11.2");

if (odbcConnectionStringBuilder.Driver == "")

{

Console.WriteLine(" ODBC Driver is not installed");

return -1;

}

odbcConnectionStringBuilder.Add("DSN", "SPORTS");

//odbcConnectionStringBuilder.Add("UID", "no-user");

//odbcConnectionStringBuilder.Add("PWD", "no-pass");

odbcConnectionStringBuilder.Add("DB", @"C:\OpenEdge\WRK\Db2.db"); // copy of database SPORTS

odbcConnectionStringBuilder.Add("HOST", "mypcname");

odbcConnectionStringBuilder.Add("PORT", "5162"); // i found this port inn the log file

using (OdbcConnection connection = new OdbcConnection(odbcConnectionStringBuilder.ConnectionString))

{

connection.Open();

try

{

odbcCommand = new OdbcCommand("SELECT COUNT(*) FROM pub.Invoice WHERE Invoicenum > 0", connection);

odbcCommand.CommandTimeout = 1;

object executeScalarResult = odbcCommand.ExecuteScalar();

RecordFound = Convert.ToInt32(executeScalarResult);

}

catch (Exception e)

{

Console.WriteLine(e.Message);

}

}

All Replies

Posted by MiguelSaucedo on 05-Jul-2013 12:11

Hi, i was trying to connect C# with Progress OpenEdge 10.1B driver by ODBC. Apparently my connection string is ok, but when i try to connect i get the following error message:

ERROR [HYC00] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver]Optional feature not implemented.
ERROR [HY000] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Server rejects connection on attach.
ERROR [IM006] [DataDirect][ODBC Progress OpenEdge Wire Protocol driver]Driver's SQLSetConnectAttr failed.

I hope you can help me.

Thanks in advance

This thread is closed