in reply to How can I import text to Access

My "old" VBScripts (not (yet) rewritten into Perl) are using the newer ADO instead of the older DAO.

Perhaps some of the responses in the threads How can I connect my perl script to an Access 2010 (.accdb) file? and/or SQL Server Compact Edition (SQL CE) on Windows 7 (64bit) are helpful?

I found these via Super Search for "ADODB", but since the topic isn't very "hot", I had to press "Next" on the first (empty) result page.

Replies are listed 'Best First'.
Re^2: How can I import text to Access
by Broggy69 (Novice) on Jan 03, 2018 at 16:17 UTC

    While this is an old post I did manage to get this figured out. Here is my code.

    my $filename = 'C:/GBowl/strawberry32/Scripts/ccname.txt'; my $db_file = 'C:/GBowl/strawberry32/Scripts/Hello.accdb'; my $dbh = DBI->connect( 'dbi:ADO:Provider=Microsoft.ACE.OLEDB.12.0;Data Source='.$db_file, ) or die $DBI::errstr; print $filelog "Connected to ms-access database\n"; #prepare and execute SQL statement $Export = $dbh->prepare( 'SELECT Company_Code, Name INTO [Text;HDR=No;DATABASE=C:\GBowl\str +awberry32\Scripts].[Plants.txt] FROM Plants ORDER BY Company_Code'); $Export->execute || die "Could not execute SQL statement ... maybe invalid?";