in reply to RE: Re: MS Access DB and WIN32::ODBC or ADO
in thread MS Access DB and WIN32::ODBC or ADO

i get the following error on my win2k system with the latest version of activestate:
-==============-
Can't call method "Sql" on an undefined value at cgi-bin lin e 8.
-==============-
i have the code written exactly as it is above, only changing the path to the .mdb file.
  • Comment on Re: RE: Re: MS Access DB and WIN32::ODBC or ADO

Replies are listed 'Best First'.
Re (4): MS Access DB and WIN32::ODBC or ADO
by RatArsed (Monk) on Aug 13, 2001 at 17:52 UTC

    Here's some more verbose code:

    use strict; use Win32::ODBC; my $DSN = "DRIVER=Microsoft Access Driver (*.mdb);FIL=MSAccess;DriverI +d=25;DBQ=c:\\my documents\\test.mdb"; my $db; my $query = "SELECT * FROM Books"; if (!($db = new Win32::ODBC($DSN))) { print "Error connecting to $DSN\n"; print "Error: " . Win32::ODBC::Error() . "\n"; } if( $db->Sql($query) ) { print "Error executing query [ \"$query\" ]\n"; print "Error: " . Win32::ODBC::Error() . "\n"; } # Debug stuff, to show return results: # $db->DumpData(); while( $db->FetchRow() ) { my %fields = $db->DataHash; print "$fields{'BookID'}: $fields{'Book Title'}\n"; } $db->Close();
    I reckon if you added error checking like this, you'd find that you're getting an error connecting to your datasource, and hopefully enough information to solve your problem?

    PS: I'd reccomend you create a user account here, and log on with it, as you then get notified when people answer you at logon.

    --
    RatArsed