[TriLUG] Re: RHEL3 ->Perl ->MSSQL
Steve Hoffman
srhoffman at gmail.com
Mon Dec 6 15:03:18 EST 2004
Just wanted to post the solution because after all the googling I was
only able to find one post that actually had the solution...naturally
the last page I looked at so there could be more...on result pages
55-100
Anyway...I didn't have enough information in the DSN...so even though
I was passing a username/password in the perl script...because it
wasn't in the ~/.odbc.ini file it wasn't working...the new ~/.odbc.ini
file looks like:
[DSN]
Description = UserDSN connection to DB
Driver = MSSQL
Servername = MSSQL
Database = database
UID = 'username'
PWD = 'password'
Port = 1433
and it works like a charm...consequently, if I remove the
username/password information from the perl script or the .odbc.ini
file it won't work (it aparently has to be in both places).
Thanks for the suggestions.
Steve
On Sun, 5 Dec 2004 23:32:47 -0500, Steve Hoffman <srhoffman at gmail.com> wrote:
> 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