It works OK even without creating a DSN with ODBC manager.
Complete working example - Access 2000 without any System.mdb,
Perl 5.6.1 build 629, DBI 1.20, DBD-ODBC 0.28
#-------------------------------------------------------
use DBI;
my $dbq = 'C:\bin\games\TkSokoban\DB\Sokoban.mdb';
my $driver = 'Microsoft Access Driver (*.mdb)';
my $dsn = "DRIVER=$driver;DBQ=$dbq";
# Username and Password are not specified: no System.mdb is used
my $dbh = DBI->connect ("dbi:ODBC:$dsn", undef, undef);
die ("connect() failed: ".$DBI::errstr) unless ($dbh);
print STDERR 'Using DBI v',$DBI::VERSION,', ',$dbh->{Driver}->{Name}, '
driver v',$dbh->{Driver}->{Version},"\n";
$sel=$dbh->prepare(<<'eof');
SELECT
ParamName, ParamValue
FROM
Config
eof
$sel->execute();
while (@data=$sel->fetchrow_array()) {
print "@data\n";
}
#-------------------------------------------------------
MaT
> -----Original Message-----
> From: Etienne Marcotte [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 23, 2001 6:30 PM
> To: Bart Lateur
> Cc: [EMAIL PROTECTED]
> Subject: Re: Problem connecting to Access DB
>
>
> It works fine with a system DSN,
>
> But when a user renames the database, you have to recreate a
> DSN each time.
>
> Is there any way to create a DNS without the database
> name/path and then
> specify it from the perl script in the connect string ?
>
> Etienne
>
> Bart Lateur wrote:
>
> > On Tue, 23 Oct 2001 10:55:57 -0400, Etienne Marcotte wrote:
> >
> > >I made an access DB, created an ODBC DNS with windows 2000 utility
> > >(altough I'm not sure I did everything correctly)
> > >
> > >When I try the connect string:
> > >
> > >dbi:ODBC:driver=Microsoft Access Driver (*.mdb);dbq=c:\\clients.mdb
> >
> > Just a thought: why aren't you simply creating a (system)
> DSN with the
> > ODBC Contol Panel, and simply reference that by name? The
> connect string
> > then can simply be
> >
> > DBI:ODBC:yourDSN
> >
> > --
> > Bart.
>