Invoking the External data dialogue from VC++

  • Thread starter Thread starter R Rihan
  • Start date Start date
R

R Rihan

I maintain a VC++ MFC application which uses DAO and an Access Database.
To import data into the Database it reads a delimited text file using File
operations.
My question is how can I invoke the Access' External data link and import
dialogue facility.
I do not know which function in DAO3.6 would activate this, OR is it in some
other DLL.

I would really appreciate some direction on this.
 
The Access import/export wizards (and Access VBA statements such as
DoCmd.TransferText) aren't available via DAO: to use them you need to
automate Access.

You can however invoke the Jet Text ISAM (which is what Access calls to
parse and import a text file) by building a SQL statement and passing it
to DAO's Database.Execute method, e.g.

INSERT INTO MyTable
SELECT F1 As FirstField, F2 As Field2, F3 As Field3
FROM [Text;HDR=No;Database=C:\MyFolder\;].MyFile#txt

If the file uses non-standard delimiters and/or text qualifiers, you
also need to have your code create a schema.ini file with an entry for
the file you're importing. See e.g.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetschema_ini_file.asp
 
Thank you very much for this info. This simplifies the task

John Nurick said:
The Access import/export wizards (and Access VBA statements such as
DoCmd.TransferText) aren't available via DAO: to use them you need to
automate Access.

You can however invoke the Jet Text ISAM (which is what Access calls to
parse and import a text file) by building a SQL statement and passing it
to DAO's Database.Execute method, e.g.

INSERT INTO MyTable
SELECT F1 As FirstField, F2 As Field2, F3 As Field3
FROM [Text;HDR=No;Database=C:\MyFolder\;].MyFile#txt

If the file uses non-standard delimiters and/or text qualifiers, you
also need to have your code create a schema.ini file with an entry for
the file you're importing. See e.g.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetschema_ini_file.asp



I maintain a VC++ MFC application which uses DAO and an Access Database.
To import data into the Database it reads a delimited text file using File
operations.
My question is how can I invoke the Access' External data link and import
dialogue facility.
I do not know which function in DAO3.6 would activate this, OR is it in some
other DLL.

I would really appreciate some direction on this.
 
Back
Top