Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How can I import text to Access

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


in reply to How can I import text to Access

Here is what I am trying in PERL #!/usr/bin/perl use strict;use warnings; use Win32::OLE; my $DBFile = qw( W:\Glenn-123456\Test\DevComm1.mdb ); # #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\VDD\Data\;HDR=No].[DevComm1.txt]"; $DB->Execute($SQLquery, 128); #128=DBFailOnError I get 4 error messages that says unrecognized escape /g /t /v /d at li +ne 11 and one can't create jet database engine line 8 Trying again.

Replies are listed 'Best First'.
Re^2: How can I import text to Access
by Broggy69 (Novice) on May 28, 2015 at 18:03 UTC
    I also tried this one just now, and I get an error saying my DevComm1. +mdb file is not found. It does exist in the folder location I specifi +ed. #!perl use strict; use warnings; use DBI; print 'bits: ' . (8 * (length pack 'P', -1)) . "\n\n"; my $DBFile = q(W:\Glenn-123456\Test\DevComm1.mdb); my $dbh = DBI->connect("dbi:ODBC:Driver={Microsoft Access Driver (*.md +b)};DBQ=$DBFile",'','') or die("cannot connect to DB"); my $SQLquery = "SELECT * INTO [Input] FROM [Text;DATABASE=W:\Glenn-123 +456\Test\\VDD\Data\;HDR=No].[DevComm1.txt]"; my $sth = $dbh->prepare($SQLquery); my $rc = $sth->execute; #Trying again

      Hi, Broggy69. Did you miss or simply decide to ignore the advice given to you by stevieb?

      Looking at your nodes on screen, don't you realise that they are an unreadable mess?

      Please read How do I post a question effectively?, and then go back and edit all your posts.

      Update: The OP seems to have taken our advice and formatted their posts, albeit not very well... but at least they're readable now!

      It may be Perl is having trouble with your Windows-style path. Try:

      my $DBFile = 'W:/Glenn-123456/Test/DevComm1.mdb';
      Dum Spiro Spero
        #!/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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-06-21 01:02 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?