Import data and write to an MSAccess database using the 4GL

From: Bylin, Bruce

Date: 24 Sep 2003


Windows 98, Progress 8.3B
 
Hi Peggers,
 
I'm looking for an example of code reading a Progress database (or importing
from a text file) and creating a table inside an MSAccess database and then
populating the MSAccess table with the input data.
 
So far, I'm able to create a new Access database, and create the table
inside it. I just don't know how to write data to this new table. Here's
what I have so far:
 
DEF VAR hAccess       AS COM-HANDLE NO-UNDO.
DEF VAR hCurrdb       AS COM-HANDLE NO-UNDO.
DEF VAR hTable        AS COM-HANDLE NO-UNDO.
DEF VAR hfield        AS COM-HANDLE NO-UNDO.
DEF VAR l-database    AS CHAR       NO-UNDO INIT "C:\work\db1.mdb".
DEF VAR l-textformat  AS INT        NO-UNDO INIT 10.
DEF VAR l-fieldLength AS INT        NO-UNDO INIT 40.
DEF VAR l-Result      AS LOG        NO-UNDO.
 
CREATE "Access.Application" hAccess.
ASSIGN
  l-Result   = hAccess:NewCurrentDatabase(l-database)
  hCurrdb    = hAccess:CurrentDb
  hTable     = hCurrdb:CreateTableDef("Customer")
  hfield     = hTable:CreateField("Name", l-textformat, l-fieldLength)
  l-Result   = hTable:Fields:Append(hfield)
  hfield     = hTable:CreateField("Address", l-textformat, l-fieldLength)
  l-Result   = hTable:Fields:Append(hfield)   /* <etc., etc.> */
  l-Result   = hCurrdb:TableDefs:Append(hTable).
END.
 
RELEASE OBJECT hAccess.
 
Any ideas on how to start populating this table? I want to be able to
control the data written to each field. 
One way that works great is this:
 
CREATE "Access.Application" hAccess CONNECT TO l-database.
hAccess:Application:docmd:TransferText(0,,"Customer","C:\work\data.txt",true
,).
RELEASE OBJECT hAccess.
 
I do not want to use this solution as I want to import this text file and
manipulate the data before writing to each field. 
Any ideas or pointers would be greatly appreciated.

Bruce Bylin 
ae0b643c-b939-8280-de11-7003f68fa0eb

�