cjhastings1 has asked for the wisdom of the Perl Monks concerning the following question:

I have Perl 5.20 Windows running with Sybase Open Client 15.7 and am having issues connecting to the database. Here is the code:
use DBI; use strict; my $database = "<server name>"; my $db = "<db name>"; my $uid = "<Sybase ID>"; my $pwd = "<Sybase Password"; my %defaults = ( AutoCommit => 1, # Autocommit enabled. PrintError => 0 # Errors not automatically printed. ); my $dbh = DBI->connect("dbi:SybaseASE:server=$database;database=$db", +"$uid", "$pwd" ); # or die "Cannot connect to $database: $DBI::errstr\n"; $dbh->disconnect; exit(0); __END__
The error I'm getting is as follows:

Can't locate loadable object for module DBD::SybaseASE in @INC (@INC contains: C:/Perl64/site/lib C:/Perl64/lib .) at ....

I can see the SybaseASE.pm module is installed in the Sybase folder, but is there a problem with Perl locating it?

Replies are listed 'Best First'.
Re: Perl 5.20 Sybase 15.7 connect to database error
by genio (Beadle) on Aug 16, 2016 at 18:32 UTC

    Your DSN string should start with "dbi:Sybase".

    However, when in Windows, it's often easier and better to just go ahead and use the ODBC driver. Here's an example.

    Just be sure to watch out for 32- vs. 64-bit drivers and the version of Perl you have installed as they must match.

    This post also covered this topic a bit.

      I was able to use the DBI:ODBC route to connect to the database. I could not use the SybaseASE or the Sybase route as it was unable to find the modules. Below is my code snippet that succeeded:
      my $dbh = DBI->connect( "dbi:ODBC:$db", "$login", "$password", { RaiseError => 1, AutoCommit => 1 } ) || err("Database Error","Can't connect to database $d +b: ". "$DBI::errstr",3);

      Thank you both for your assistance with this matter.

Re: Perl 5.20 Sybase 15.7 connect to database error
by Corion (Patriarch) on Aug 16, 2016 at 17:59 UTC

    In addition to the Sybase Perl modules and DLLs, you will also likely need some more Sybase DLLs to be in $ENV{PATH}. This most likely means that you will also need the Sybase client installed.

      I do have 64-bit Sybase 15.7 open client installed. Thanks for the advice though.

        More things to check are whether $ENV{PATH} also includes the Sybase directories where the Sybase DLLs live. Also, maybe $ENV{SYBASE_ASE} and/or $ENV{SYBASE_OCS} need to be set? On my system, I also have $ENV{SYBROOT} set, but I use ODBC for connecting.

Re: Perl 5.20 Sybase 15.7 connect to database error
by VinsWorldcom (Prior) on Aug 16, 2016 at 19:25 UTC

    I think "loadable object" is referring to the DLL compiled as part of an XS module. I can't find DBD::SybaseASE on CPAN but the regular DBD::Sybase module is XS and thus will have a Sybase.dll in the same @INC folder as the Sybase.pm module file.