Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^4: How can I import text to Access

by Broggy69 (Novice)
on May 28, 2015 at 19:58 UTC ( #1128182=note: print w/replies, xml ) Need Help??


in reply to Re^3: How can I import text to Access
in thread How can I import text to Access

#!/usr/bin/perl use strict;use warnings; use Win32::OLE; my $DBFile = 'W:/Glenn-123456/Test/DevComm1.mdb' #my $DBFile = qw( W:\\Glenn-123456\\Test\\DevComm1.mdb ); #my $MSACCESS_DSN ='Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$DBF +ile ;Persist Security Info=False;'; #my $msaccess_dbh = DBI->connect("dbi:ODBC:$MSACCESS_DSN"); #Choose appropriate version of Jet for your system my $Jet = Win32::OLE->CreateObject('DAO.DBEngine.36') or die "Can't +create Jet database engine."; my $DB = $Jet->OpenDatabase( $DBFile ); my $SQLquery = "SELECT * INTO [Input] FROM [Text;DATABASE=W:\Glenn-123 +456\Test\;HDR=No].[DevComm1.txt]"; $DB->Execute($SQLquery, 128); #128=DBFailOnError #Still no look. tried a few things that are commented out. #But I have + new errors. #Unrecognized esape \G & \T line 14 #Syntax error line 12 near "my " #Global symbol "$Jet" requires explicit package name line 12 #Global symbol "$Jet" requires explicit package name line 13 #Global symbol "$DBFFile" requires explicit package name #line 13

Replies are listed 'Best First'.
Re^5: How can I import text to Access
by GotToBTru (Prior) on May 28, 2015 at 20:01 UTC

    Missing ; at the end of the my $DBFile line.

    Dum Spiro Spero
      #!/usr/bin/perl use strict; use warnings; use Win32::OLE; my $DBFile; my $Jet; my $DB; my $SQLquery; $DBFile = 'W:/Glenn-123456/Test/DevComm1.mdb'; #my $DBFile = qw( W:\\Glenn-123456\\Test\\DevComm1.mdb ); #my $MSACCESS_DSN ='Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$DBF +ile ;Persist Security Info=False;'; #my $msaccess_dbh = DBI->connect("dbi:ODBC:$MSACCESS_DSN"); #Choose appropriate version of Jet for your system; $Jet = Win32::OLE->CreateObject('DAO.DBEngine.36') or die "Can't cre +ate Jet database engine."; $DB = $Jet->OpenDatabase( $DBFile ); $SQLquery = "SELECT * INTO [Input] FROM [Text;DATABASE=W:/Glenn-123456 +/Test/;HDR=No].[DevComm1.txt]"; $DB->Execute($SQLquery, 128); #128=DBFailOnError #Ok here is updated code, but still getting an error #Can't create Jet Database engine at line 17

        And now you're in the realm of OLE errors, and I can't help there (others here might). Perhaps Win32::OLE->LastError() contains some useful information?

        Dum Spiro Spero

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1128182]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-06-21 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (117 votes). Check out past polls.

    Notices?