http://www.perlmonks.org?node_id=1223732
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I want to connect to a MSSQL server and catch a connection error if it happens. I used to use on MySQL an eval which, as far as I remember worked fine. However, I can not catch an error if it happens now, if for example the password is wrong. This is what I am using:

print "Connecting to MSSQL terminology database... "; eval{ $dbh = DBI->connect("dbi:ODBC:Driver={SQL Server};Server=$SqlDatabase +Name;UID=$SqlDatabaseUser;PWD=$SqlDatabasePassword", {PrintError => 0 +, RaiseError => 1, AutoCommit => $AutoCommit, FetchHashKeyName => 'NA +ME_lc',}) ; $dbh->{'mysql_enable_utf8'} = 1; }; if ($@) { print "ERRRRRRRRRRRROR\n"; }

Any idea what I am doing wrong?