Something must be wrong with the DSN you setup for this database, if the first error message is right.
Ahh -- I see it now. It's much more obvious and subtle than any of that. When using '' instead of "", $dsn is not referenced as a variable. E.g. my $dsn="foo"; print '$dsn'; #prints $dsn vs. print "$dsn"; #prints foo Jeff > -----Original Message----- > From: Liu Haifeng [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 28, 2002 10:34 PM > To: Jeff Urlwin; [EMAIL PROTECTED] > Subject: Re: Failure of ODBC connection with Access > > > Answers to your questions: > 1. Error messages (testdb.pl is the name of my program): > DBI->connect($dbn) failed: [Microsoft][ODBC Driver Manager] > Data source > name not found and no default driver specified > <SQL-IM002><DBD:db-login/SQLConnect err=-1> at testdb.pl line 22 > [Microsoft][ODBC Driver Manager] Data source name not found and no > default driver specified <SQL-IM002><DBD:db-login/SQLConnect err=-1> > > 2. Microsoft Access Driver version: 4.00.5353.01 > 3. I login in to my PC as administaitor and the database file > was built by > myself. > > Regards > Haifeng > ----- Original Message ----- > From: "Jeff Urlwin" <[EMAIL PROTECTED]> > To: "Liu Haifeng" <[EMAIL PROTECTED]>; "Jeff Urlwin" > <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Thursday, August 29, 2002 10:17 AM > Subject: RE: Failure of ODBC connection with Access > > > > I have a few questions: > > > > What's the error message? > > What version of the Access ODBC driver are you using? > > Do you have access to the path/file? > > > > Regards, > > > > Jeff > > > > > > Thanks to Jeff first, but I still failed in both ways either > by DSN-less > > > connection or by system DSN connnection. > > > .... > > > #my $dbn="driver=Microsoft Access Driver > (*.mdb);dbq=\\\\genethon\\data > > > drive\\www\\DB\\newgene.mdb"; > > > my $dbn="newgene"; > > > my $dbh=DBI->connect('dbi:ODBC:$dbn','','')|| die "$DBI::errstr\n"; > > > ... > > > where "newgene" is a system DSN I have added. > > > > > > I do use DBD::ODBC 0.28. Any more suggestions? > > > > > > Regards > > > Haifeng > > > > > > ----- Original Message ----- > > > From: "Jeff Urlwin" <[EMAIL PROTECTED]> > > > To: "Liu Haifeng" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > > > Sent: Wednesday, August 28, 2002 8:32 PM > > > Subject: RE: Failure of ODBC connection with Access > > > > > > > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > >