C# to connect to a Progress Database

时光毁灭记忆、已成空白 提交于 2019-12-08 13:28:32
jon825
string connectString = "DSN=QADDB;uid=username;pwd=password;host=hostname;port=port#;db=dbname;";
using (OdbcConnection dbConn = new OdbcConnection(connectString));
{
    try
    {
        dbConn.Open();
    } catch (Exception)
    {
        mRtnVar = "Couldn't Connect";
        return mRtnVar
    }   
    string sqlstr = string.Format(@"SELECT ""FieldName"" FROM PUB.DataBase WHERE ""FieldName"" = 'value'");
    using (OdbcCommand comm = new OdbcCommand(sqlstr, dbConn))
    {
        using (OdbcDataReader reader = dbConn.ExecuteReader())
        {
            if (reader.Read())
            {
                mRtnVar = reader["FieldName"].ToString();
            }
        }
    } 
    return mRtnVar
}      

In your connection string, set the port of your Progress database:

PORT=20931;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!