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");
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.