At 03:34 PM 14-05-01 -0600, Jorge L. Allen wrote:

>It is first time connecting to Microsoft Access, and I cannot even  make a
>simple connection.
>
>The database is running and connected to the web using dreamweaver.
>But I need to write perl scripts to update it.
>
>use DBI;
>
>$dsn = qq(dbi:Microsoft Access
>   Driver:D\:\\\\Inetpub\\wwwroot\\temp\\doc_archive_test.mdb);
>my $dbh = DBI->connect($dsn);
>
>
>This is the error message:
>
>Can't connect (dbi:Microsoft Access
>Driver:d:\\Inetput\wwwroot\temp\doc_archive_test.mdb), no database driver
>specified and DBI_DSN env var not set at <script name>.
>
>
>Isn't the driver named "Microsoft Access Driver"
>
>I know it is installed in the system DSN.
>
>any help is appretiated.

Jorge,

The following is a step-by-step explanation.  I know you've aready done the 
DSN part, but this may help others who haven't got that far.

1. Make a DSN entry for the database:
         Win2000: Go to Administrative Tools|Data Sources (ODBC),
         Win95/98: Control Panel|ODBC connectivity,
         System DSN
         Add...
         Type a DSN name (refered to as NEW_DSN_NAME below)
         The user name and password will be needed for your script.
2. Try connecting from perl:
         use strict;
         use DBI;
         my $dbh = DBI->connect('dbi:ODBC:NEW_DSN_NAME', 'USER_NAME', 
'PASSWORD')
                 or die "Can't open database";
         my $sQuery = "SELECT * FROM TABLE_ABC;";
         eval
                 {
                 my $sthAllABC = $dbh->prepare($sQuery);
                 $sthAllABC->execute;
                 my $raEntry = $sthAllABC->fetchrow_arrayref();
                 while($raEntry)
                         {
                         print "First field is " . $raEntry->[0] . "\r\n";
                         $raEntry = $sthAllABC->fetchrow_arrayref();
                         }
                 $sthAllABC->finish;
                 };
         if($@)
                 {
                 print "Query failed because $@\r\n";
                 exit 1;
                 }
         $dbh->disconnect;

Hope this helps.

Joe Yates

Reply via email to