in reply to Perl DBI Question

This should help you, just check return code from connect(): (Tested and worked, I have web, but not weeb)

use DBI; use strict; use warnings; my $dbi; my @databases = ('dbi:ODBC:weeb', 'dbi:ODBC:web'); for (@databases) { print "attempt connect to database $_\n"; if ($dbi = DBI->connect($_,"","",{AutoCommit=>1})) { print "connected to database $_\n"; last; } }

Replies are listed 'Best First'.
Re: Re: Perl DBI Question
by hmerrill (Friar) on Jan 21, 2004 at 21:56 UTC
    Or to be a little bit more general for the original poster:
    use DBI; use strict; use warnings; my $dbh; my $dsn = 'dbi:ODBC:web'; my $user = 'some'; my $pass = 'thing'; if ($dbi = DBI->connect($dsn, $user, $pass, {AutoCommit=>1})) { print "connected to database $_\n"; } else { print "did not connect to database\n"; print "try connecting to another database here??\n"; }
    HTH.