>
> Hi,
>
> I am wondering how to successfully connect to Microsoft Access
> database using DBD::ODBC. Here is the snippet of my code:
Use perldoc DBD::ODBC and you will see an example of a DSN-less connection,
which is what you are trying to do. Otherwise, setup a system DSN and use
DBI->connect("dbi:ODBC:$DSN", etc)
>
> .....
> my $dbdrive=DBI->install_driver('ODBC');
> my $dbn="driver=Microsoft Access Driver
> (*.mdb);dbq=\\\genethon\\data drive\\www\\DB\\newgene.mdb";
> my $dbh=$dbdrive->connect('dbi:ODBC:$dbn','','')|| die "$DBI::errstr\n";
> ....
Thre are two problems here:
1) you should never need to call install_driver. Just use DBI->connect()
2) Your dbq= has a missing backslash in front of the server name (3 instead
of 4)
> where "genethon" is my PC name and the database file
> "newgene.mdb" actually locates under C:\data drive\www\DB.
>
> The error message is "[Microsoft][ODBC Driver Manager] Data
> source name not found and no default driver specified
> <SQL-IM002><DBD:db-login/SQLConnect err=-1>"
>
Also, check which version of DBD::ODBC you are using. There were some
spurious error messages in the .28 when using a long name connecting like
this. I think you'll be ok, but...
Regards,
Jeff