[TriLUG] RHEL3 ->Perl ->MSSQL

Steve Hoffman srhoffman at gmail.com
Sun Dec 5 23:32:47 EST 2004


Anyone here have any luck connecting perl to MSSQL from Linux?  I've
installed the following:
unixODBC
freeTDS
DBD:ODBC

and configured everything as best I could, but I can't get it to
connect...always get an error:

DBI connect('DSN','username',...) failed: [unixODBC][FreeTDS][SQL
Server]Unable to connect to data source (SQL-08001)(DBD:
db_login/SQLConnect err=-1) at ./testSQL line 6

and the script I'm running to test is below

#!/usr/bin/perl
#
use strict;
use DBI;

my $dbh = DBI->connect('dbi:ODBC:DSN', 'username', 'password');
$dbh->disconnect if ($dbh);

the DSN you see in the error and the script is actually the DSN the
~/.odbc.ini file:
[DSN]
Driver          = MSSQL
Description     = Database
Trace           = No
Server          = SQL2K      #from /etc/freetds.conf
Database        = database

the freetds.conf entry:
# A typical Microsoft SQL Server 2000 configuration
[SQL2K]
        host = dbserv.domain.com
        port = 1433
        tds version = 8.0

and the odbcinst.ini:
[MSSQL]
Description             = Connection to MSSQL Database
Driver          = /usr/lib/libtdsodbc.so
FileUsage               = 1


switching database servers isn't an option...half my company has their
lips firmly planted on the microsoft tit (or is it teet?).  I
basically just need to get this working... Anyone who's done this care
to share any words of wisdom?

Thanks as usual!
Steve



More information about the TriLUG mailing list