I'm trying to connect to a MS-SQL Database using perl and freetds. I have tested the installation of freetds using the unix commandline
`/usr/local/exec/bin/tsql -S myDB -I freetds.conf -U userName -P passw0rd -D DataBase1 -o q < query.sql`
where query.sql
contains my sql query. It runs perfectly well. But when I try the same with perl it gives me the following error -
`Your sybase home directory is /opt/sybase. Check the environment variable SYBASE if it is not the one you want! Cannot access file /opt/sybase/config/objectid.dat`
but running
$ set | grep SYBASE
yields SYBASE=/usr/fsf/freetds
Below is my perl code:
#!/usr/bin/perl5/core/5.8.8/exec/bin/perl
use lib qw(/usr/perl5/core/5.8.8/exec/lib);
use lib qw(/usr/perl5/DBI/1.607/exec/5.8/lib/perl5);
use lib qw(/usr/perl5/DBD-Sybase/1.09/exec/5.8/lib/perl5);
use DBI;
use DBD::Sybase;
my $user = "userName";
my $passwd = "passw0rd";
my $server = "myDB";
`export SYBASE=/usr/fsf/freetds`;
`export LD_LIBRARY_PATH=/usr/fsf/freetds/0.82/exec/lib`;
`export FREETDSCONF=./freetds.conf`;
my $dbh = DBI->connect("DBD:Sybase:server=$server", $user, $passwd, {PrintError => 0});
unless ($dbh) {
die "ERROR: Failed to connect to server ($server).\nERROR MESSAGE: $DBI::errstr";
}
else {
print "\n";
print "Successful Connection.";
}
Any help much appreciated!