Connect to MS SQL 2005 server from UNIX

S

Slickuser

Hi,

I'm trying to connect to MS SQL 2005 server from UNIX. But I get the
warning below.

I can connect through C#.NET fine using the same server, user &
password.
Any idea why?

Here's the perl code:

#!/usr/local/bin/perl

use strict;
use warnings;

use DBI;

my $server = "xxx";
my $user = "xxx";
my $password = "xxx";
my $dbname = "xxx";


my @available_drivers = DBI->available_drivers;
print ("The available DBD drivers are: @available_drivers.\n");

my $dbh = DBI->connect("dbi:Sybase:$server", "$user", "$password")
or die "Cannot log into $server\n";



login> perl testSQL.pl
The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.
src/tds/login.c: tds_connect: x.x.x.x:4000: Connection refused
DBI connect('xxx','xxx',...) failed: OpenClient message: LAYER = (0)
ORIGIN = (0) SEVERITY = (78) NUMBER = (41)
Server xxx, database
Message String: Server is unavailable or does not exist. at testSQL.pl
line 17
Cannot log into xxx
 
D

Dan Rumney

login> perl testSQL.pl
The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.
src/tds/login.c: tds_connect: x.x.x.x:4000: Connection refused
DBI connect('xxx','xxx',...) failed: OpenClient message: LAYER = (0)
ORIGIN = (0) SEVERITY = (78) NUMBER = (41)
Server xxx, database
Message String: Server is unavailable or does not exist. at testSQL.pl
line 17
Cannot log into xxx

This isn't really a Perl question, since the problem you're having is
with the connection to your database.

If I were getting this problem, the first thing I'd check is that port
4000. Is that the correct port?
I'd also look at my Sybase docs and try and determine what the LAYER,
ORIGIN, SEVERITY, NUMBER messages meant.

Hope that helps, but you probably want to be talking to some Sybase
people about this issue, not Perl
 
S

Slickuser

I tried the specific port (1433) and get this error:

The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.
DBI connect('server=xxx,1433','xxx',...) failed: (no error string) at
testSQL.p



If I tried the IP then I get this:

The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.

DBI connect('server=IPXXX,1433','xxx',...) failed: (no error string)
at
Cannot log into xx.xx.xx.xx,1433

On windows, I can connect fine to using ODBC with ip or server name
(no port or with port 1433).
 
S

Slickuser

This isn't really a Perl question, since the problem you're having is
with the connection to your database.

If I were getting this problem, the first thing I'd check is that port
4000. Is that the correct port?
I'd also look at my Sybase docs and try and determine what the LAYER,
ORIGIN, SEVERITY, NUMBER messages meant.

I tried to use the specific port but it doesn't work either.

Here's the log:

The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.

DBI connect('server=xxx,1433','xxx',...) failed: (no error string) at
testSQL.p



The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.

DBI connect('server=IPXXX,1433','xxx',...) failed: (no error string)
at
Cannot log into xx.xx.xx.xx,1433
 
J

J. Gleixner

Slickuser said:
I tried to use the specific port but it doesn't work either.

Here's the log:

The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.

DBI connect('server=xxx,1433','xxx',...) failed: (no error string) at
testSQL.p



The available DBD drivers are: DBM ExampleP File ODBC Pg Proxy SQLite
Sponge Sybase mysql.

DBI connect('server=IPXXX,1433','xxx',...) failed: (no error string)
at
Cannot log into xx.xx.xx.xx,1433

Can you connect to the port on that server from your machine?

telnet your.server.name 1433

Does the database allow connections from your machine for that username
and password?
 
S

Slickuser

Can you connect to the port on that server from your machine?

telnet your.server.name 1433

I cannot by telnet.
Does the database allow connections from your machine for that username
and password?

I can log-in with provided user&password from Win32:ODBC or Microsoft
SQL management from Windows side.
 
J

J. Gleixner

Slickuser said:
I cannot by telnet.

Just to be clear. You don't get a connection using telnet? e.g.
you don't see..

Trying some.ip.ad.dress...
Connected to some.machine.name
Escape character is '^]'.

You can't actually do anything via telnet, however it should
connect to the port. If it doesn't then "there's your problem
right there", or at least one of the problems. Contact
your Network/Firewall folks.
I can log-in with provided user&password from Win32:ODBC or Microsoft
SQL management from Windows side.

But, you're using a different machine running some flavor of Unix,
right? There are many reasons why connecting from another
machine/OS/IP wouldn't be allowed, none having to do with Perl.
 
S

Slickuser

I cannot by telnet.

Just to be clear. You don't get a connection using telnet? e.g.
you don't see..

Trying some.ip.ad.dress...
Connected to some.machine.name
Escape character is '^]'.

You can't actually do anything via telnet, however it should
connect to the port.  If it doesn't then "there's your problem
right there", or at least one of the problems. Contact
your Network/Firewall folks.

If I do > telnet server 1433
I have my command prompt windows title to be: "Telnet server" and the
cursor is blinking.

But, you're using a different machine running some flavor of Unix,
right? There are many reasons why connecting from another
machine/OS/IP wouldn't be allowed, none having to do with Perl.

But this user/password has nothing to do Unix.
If I can connect from Windows using perl Win32 ODBC, C#.net SQL
command, and SQL Management (same user/password from SQL Database).
Then I should be able to connect through Unix with the same user/
password.

I still don't know why though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top