Highlighted
Absent Member.
Absent Member.
1147 views

[archive] Access 2007

[Migrated content. Thread originally posted on 05 February 2009]

Hello
Is there a .def file that will allow us to import records to an Access 2007 .accdb database?

Thanks
0 Likes
4 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Access 2007

The .def file you make yourself using axdefgen, launch it, go to the library tab, scroll down until you find Microsoft ActiveX Data Objects, there is likely to be multiple of them, pick anyone you want.

As for how to import, I am not sure there is a specific import example, but I am pretty sure I once posted an example here of how to read records using MS ADO. Look around.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Access 2007

Here is an example on accessing MS Access from ACUCOBOL-GT:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ExReadADO.
      *====================
      *
      * Copyright (c) 1996-2006 by Acucorp, Inc.  Users of ACUCOBOL
      * may freely modify and redistribute this program.
      *
      * The purpose of this application is to illustrate use of the MSADO
      * technology for database access
      *
       ENVIRONMENT DIVISION.
       CONFIGURATION                SECTION.
       SPECIAL-NAMES.
           COPY    "MSADO.def".
                   .
       DATA        DIVISION.
       WORKING-STORAGE              SECTION.
       
       77 hConnection               HANDLE OF Connection.
       77 hRecordset                HANDLE OF Recordset.
       77 ConnStr                   PIC X(256).
       77 WS-ConnStat               PIC S9(9).
       77 WS-RecCount               PIC 9(9).
       77 WS-String                 PIC X(1024).
       77 WS-Last                   PIC X(30).
       77 WS-First                  PIC X(30).
       PROCEDURE DIVISION.
       Main section.
       Main-001.
      *Create an instance of the Excel Application object.
           CREATE  Connection       OF ADODB
                   HANDLE           IN hConnection.
           Create  Recordset        OF ADODB
                   HANDLE           IN hRecordset.
           STRING  "Driver={Microsoft Access Driver (*.mdb)};"
                   "Dbq=apiv2db.mdb;"
                   "DefaultDir=F:\APIV2\DocExamples\MSADO;"
                   "ReadOnly=False"
                   DELIMITED        BY SIZE INTO ConnStr.
           MODIFY  hConnection      @Open(ConnStr).
           INQUIRE hConnection      State IN WS-ConnStat.
           IF      WS-ConnStat      NOT = adStateOpen
                   GO TO            MAIN-900
                   END-IF.
      * This variant uses the connection as a basis for the selection
      *    MODIFY  hConnection      Execute("Select * from Contacts",
      *            WS-RecCount,     adCmdText)
      *            GIVING           hRecordset.
     
   
           MODIFY  hRecordset       MaxRecords = 100.
           MODIFY  hRecordset       @Open(
                   BY NAME Source   
                   "Select * FROM Contacts ORDER BY LastName",
                   BY NAME ActiveConnection hConnection,
                   BY NAME Options adCmdText).
           MODIFY  hRecordset       MoveFirst().
           INQUIRE hRecordset       EOF IN WS-ConnStat.
           PERFORM UNTIL            WS-ConnStat = -1
                                   
                   INQUIRE          hRecordSet
                                    fields::item("FirstName")::value
                                    IN WS-First
                                    fields::item("LastName")::value
                                    IN WS-Last
                   INITIALIZE       WS-String
                   STRING           WS-Last DELIMITED BY SPACE
                                    ", " DELIMITED BY SIZE
                                    WS-First DELIMITED BY SPACE
                                    INTO WS-String
                   DISPLAY          WS-String(1:62)
                   IF               WS-ConnStat NOT = -1
                                    MODIFY  hRecordset MoveNext()
                                    END-IF
                   INQUIRE          hRecordset EOF IN WS-ConnStat
           END-PERFORM.
           ACCEPT  OMITTED.
           MODIFY  hRecordset       @Close().
           MODIFY  hConnection      @Close().
       MAIN-900.   
      *Finish up.
    DESTROY hRecordset.
    DESTROY hConnection.
           GOBACK.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Access 2007

Thanks for your help.
My program works for Access 2003, but when I change my string command:

STRING "Driver={Microsoft Access Driver (*.accdb)};"
"Dbq=Pool Tables.accdb;"
"DefaultDir=U:\WorkingFiles;"
"ReadOnly=False"
DELIMITED BY SIZE INTO ConnStr.

from .mdb to .accdb for Access 2007 my program no longer works
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Access 2007

Never mind. I figured it out. I had to download and run AccessDatabaseEngine.exe for Access 2007 from microsoft to set up the driver.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.