Read Data From AcuCobol File...

Hi all,
my enterprise software platform runs on AcuCobol. I would like to access the data produced by it in C #. I installed AcuODBC and through WinSql can query the database, but I can not do the same via an ASP.NET page that uses the same ODBC connection. You know you help me?

thanks a lot

  • A few questions .. is the ASP.Net running on the same server as the data? Is the ASP.Net using  ADO to query the data? Is your AcuODBC DSN a file DSN or System DSN?

  • is the ASP.Net running on the same server as the data?

    ------>YES

    Is the ASP.Net using  ADO to query the data?

    this is my Code below....

    string connectionString ="DSN=GESA";

           string sql = "select * from GEDAMAGA where codice_articolo='7659'";

           OdbcConnection conn = null;

           OdbcCommand comm = null;

           OdbcDataReader dr = null;

           try

           {

               conn = new OdbcConnection(connectionString);

               conn.Open();

               DataTable dt = conn.GetSchema(OdbcMetaDataCollectionNames.Tables);

               comm = new OdbcCommand(sql, conn);

               dr = comm.ExecuteReader();

               while (dr.Read())

               {

                   Response.Write(dr.GetValue(0).ToString());

                   Response.Write(dr.GetValue(1).ToString());

                   Response.Write(dr.GetValue(2).ToString());

               }

               dr.Close();

           }

           catch (OdbcException oe)

           {

               Response.Write("An ODBC exception occurred: " oe.Message.ToString());

           }

           catch (Exception ex)

           {

               Response.Write("An exception occurred: " ex.Message.ToString());

           }

           finally

           {

               if (conn.State == System.Data.ConnectionState.Open)

               {

                   conn.Close();

               }

               comm.Dispose();

               conn.Dispose();

           }

    The DSN in A SYSTEM DSN.....



    this is the error:

    An ODBC exception occurred: ERROR [42S02] [Acucorp][ODBC AcuODBC driver]Base table or view not found: File GEDAMAGA does not exist or bad XFD record length


    the same query in WinSql work fine...

  • I believe the issue is environment variable related ... when running the Winsql query you had GENESIS_HOME set, whereas the ASP.Net is run by some other account and GENESIS_HOME is probably not set. Can you make sure that GENESIS_HOME is set.

  • In the account where I use WinSql There is no variable called GENESIS_HOME....

  • Chapter 5:Installing AcuXDBC > 5.2 Installing AcuXDBC/AcuXDBC Server >

    5.2.1 Windows Installations ... The installation process sets an environment variable known as GENESIS_HOME with the location for configuration files and the installation directory. The default installation directory is C:\Program Files\Micro Focus\Acucbl9xx\AcuGT\ on Windows. Though you can have several different configuration files and refer to different ones in your DSNs, they must always reside in the directory pointed to by GENESIS_HOME.

  • ok, but i have no genesis_home variable and my winsql can query acuODBC driver...Why?

  • That one is harder to explain, however if you start the query in the directory where GENESIS_HOME would be set to (usually the AcuGT\acucbl9xx directory) then the query would succeed. On Windows you can check Control Panel\All Control Panel Items\System\Advance System settings\Environment variables .. it is possible that Genesis_Home is set for the user and not for the System.

  • Verified Answer

    You are using the old AcuODBC product so genesis_home does not apply.  However I suspect the problem is still with the environment.  Specifically, the location specified in the DSN, Data Directory setting.  Is that using a mapped drive to a remote server?  If so then likely the environment where your ASP.NET page is executing doesn't know that mapping.  If this is the case try using UNC notation instead.