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

I am trying to connect to a remote MSSQL server that is at a specific IP address.
I am running Perl on Windows
I have the DBI modules installed.
My perl script is able to connect to a MSSQL server that is on my local network.
All other programs (ODBC administrator, SQL Management Studio, Local C# programs) are able to connect to the remote server, but my PERL script is not.

I have tried creating a system DSN, and tried several suggested styles for the connect string, but each time I get an error that says the Data Source Name or default dreiver is not specified.

dbi:ODBC:$dsn;

dbi:ODBC:DSN=$dsn;

When I build a proper DSN-less connect string the connection fails with an error that says invalid connection:

dbi:ODBC:Driver={SQL Server};Server=$ipaddress;Database=$database;UID=$uid;PWD=$pwd;

dbi:ODBC:Driver={SQL Server};Server=$ipaddress:1433;Database=$database;UID=$uid;PWD=$pwd;

These connect strings work in other programs (written in various languages) on this computer, they simply don't work in my Perl program.

I must stress these things:

The Perl program is able to connect to a database on my LAN by simply changing the ip-address of the remote server with a server name on the local network.

Other programs are able to connect to the remote server, using the same connect string with the ip-address.

Replies are listed 'Best First'.
Re: Connecting to a remote MSSQL server
by poj (Abbot) on Feb 10, 2012 at 18:26 UTC
    With a system DSN called ABC that tests ok it should connect using
    my $dbh = DBI->connect('DBI:ODBC:ABC',$uid,$pwd);
    poj
Re: Connecting to a remote MSSQL server
by mje (Curate) on Feb 13, 2012 at 10:08 UTC

    Are you running this script on Windows 64 platform and is your Perl 32 bit or 64 bit? If you are on Windows 64 read on... You can create a 64 DSN and it is not visible from a 32 bit application and vice versa but it is a whole lot more complicated than this. Try reading ODBC on 64-bit Windows Platforms, it should help explain all this.