I am using perl 5.24. I am trying to learn Perl.
I had written a simple Perl code to connect to a DB. But gives error stating
DBI connect('database=vms','DBA',...) failed: (no error string) at simpleperl.pl line 13.
The code is
#!/usr/bin/perl
use DBI;
use DBD::SQLAnywhere;
my $driver = "SQLAnywhere";
my $database = "vms";
my $dsn = "DBI:$driver:database=$database";
my $userid = "DBA";
my $password = "admin";
my $dbh = DBI->connect($dsn, $userid, $password,{RaiseError => 1}) or die ("died connection:$DBI::errstr");
if($dbh)
{
print "Connection Established";
}
Can anyone point out what might be the problem here?
use strict;anduse warnings;as those will catch a bunch of errors. And don'tuse DBD::<Driver>directly.DBIwill handle the driver for you.database=$databasemust beENG=$database. See te comment in the source code:# If dbname starts with something that doesn't look like # a connect string parameter ('label=value;' format) then # 'ENG=' is prefixed.