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");

In reply to Connecting to sqlserver2008 - DBD::Sybase connectivity and unixODBC issue by venu_hs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.