http://www.perlmonks.org?node_id=1018340

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

Hi Monks, we are trying to connect to sqlserver 2008 from a perl script using DBD::Sybase. could you please help. This is a bit urgent... We got the below error when we try to run the script... Message String: ct_connect(): directory service layer: internal directory control layer error: Requested server name not found.

Below is the code:

#!/usr/bin/perl use strict; use DBI; use DBD::Sybase; my $user="abc"; my $auth='defv'; my $srvr = 'abc.cde.corp.org\XYZ'; # Connect to the SQL Server Database my $dbh = DBI->connect("dbi:Sybase:server=${srvr};database=TEST", $use +r, $auth,{PrintError => 0,RaiseError => 1, ShowErrorStatement => 1,}) +; my $sql = "SELECT USER"; my $sth = $dbh->prepare( $sql ); $sth->execute(); my @data; if($sth->execute) { while ( @data = $sth->fetchrow ) { print "@data\n"; } } $sth->finish(); undef $sth; $dbh->disconnect();

Then we also tried the option of using unixODBC But still could not solve the issue as we got a different error...

Here is the error: DBI connect('DRIVER={SQL Server};Server=abc.cde.corp.org\XYZ;Database=TEST;UID=abc;PWD=defv','',...) failed: unixODBCDriver ManagerCan't open lib 'SQL Server' : file not found (SQL-01000)

below is the code:

#!/usr/bin/perl -w use strict; use DBI; use DBD::ODBC; my $user = q/abc/; my $password = 'defv'; my$dbh1 = DBI->connect("dbi:ODBC:DRIVER={SQL Server};Server=abc.cde.co +rp.org\\XYZ;Database=TEST;UID=$user;PWD=$password");