sprakash has asked for the wisdom of the Perl Monks concerning the following question:

Hi! this script executues perfectly and allbut it does not gte the data from the database in the "_private" directory on my web host. Is it some syntax error or slash error or my part or........ Please help.
use strict; use OLE; my $dbh; $dbh = CreateObject OLE "ADODB.Connection" or die "Can't create connec +tion to DataBase: $!" unless $dbh; $dbh->Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=\_private\db1 +.mdb"); my $sqlstatement="SELECT email,password FROM surya"; my $rs = $dbh->Execute($sqlstatement); while (!$rs->EOF()) { print $rs->Fields('email')->Value . " " . $rs->Fields('password')- +>Value . "\n"; $rs->MoveNext; }
  • Comment on Can anyone help me -- this code executes but does not get data from MS Access database on web host
  • Download Code

Replies are listed 'Best First'.
Re: Can anyone help me -- this code executes but does not get data from MS Access database on web host
by BigJoe (Curate) on Dec 14, 2000 at 18:46 UTC
    If you do it the way you are doing it you may need to create server variables out of the $rs. Just like how you created the connection you need to make $rs into a record set. My guess (from using asp) is:
    my $rs = CreateObject OLE "ADODB.Recordset" or die "can not create rec +ordset"; $rs->open($sqlstatement, $dbh, 3, 3);
    so you code would look like :
    use strict; use OLE; my $dbh; $dbh = CreateObject OLE "ADODB.Connection" or die "Can't create connec +tion to DataBase: $!" unless $dbh; $dbh->Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=\_private\db1 +.mdb"); my $rs = CreateObject OLE "ADODB.Recordset" or die "can not create rec +ordset"; my $sqlstatement="SELECT email,password FROM surya"; $rs->open($sqlstatement, $dbh, 3, 3); while (!$rs->EOF()) { print $rs->Fields('email')->Value . " " . $rs->Fields('password')- +>Value . "\n"; $rs->MoveNext; }


    --BigJoe

    Learn patience, you must.
    Young PerlMonk, craves Not these things.
    Use the source Luke.
Re: Can anyone help me -- this code executes but does not get data from MS Access database on web host
by mrmick (Curate) on Dec 14, 2000 at 20:56 UTC
    Another option could be to use DBI::ODBC or WIN32::ODBC.

    I have used these before with Access and they worked fine.

    Mick