Skip to Content.
Sympa Menu

freetds - Re: [freetds] issues connecting with perl DBD::ODBC

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Kulik, Scott" <SKulik AT severstalna.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] issues connecting with perl DBD::ODBC
  • Date: Tue, 23 Jun 2009 11:03:10 -0400

Anyone have any luck getting connected to a SQL server database with
DBD::ODBC in perl? I'm hoping to try to get this issue fixed this week
but I'm out of ideas.

Thanks
Scott K

-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Kulik, Scott
Sent: Friday, June 19, 2009 5:20 PM
To: freetds AT lists.ibiblio.org
Subject: [freetds] issues connecting with perl DBD::ODBC

Hi,



I am trying to connect to a SQL Server from perl. I have successfully
configured ODBC and freetds under Redhat Linux ES4 and am able to
connect with tsql and isql. For some reason though, the test perl
connection script is coming back with an error.



Here is my info:



[root@trafficdev1 root]# cat /etc/odbc.ini

[PTT]

Driver = FreeTDS

Description = ODBC via FreeTDS

Servername = SPT-SQL02

Database = PTT



[root@trafficdev1 root]# cat /etc/odbcinst.ini

# Driver from freetds package

[FreeTDS]

Description = ODBC for SQL Server

Driver = /usr/local/lib/libtdsodbc.so

Setup = /usr/lib/libtdsS.so



/usr/local/etc/freetds.conf

[SPT-SQL02]

host = SPT-SQL02.DOMAIN.COM

port = 1433

tds version = 8.0

client charset = UTF-8



Here is the sample perl script I am using from the freetds site:



#!/usr/bin/perl



use DBI;



my $dbh = DBI->connect('dbi:ODBC:PTT', 'user', 'pass', {PrintError =>
0});



die "Unable for connect to server $DBI::errstr"

unless $dbh;



my $rc;

my $sth;



$sth = $dbh->prepare("select \@\@servername");

if($sth->execute) {

while(@dat = $sth->fetchrow) {

print "@dat\n";

}

}



Here is the output from the script:

[root@trafficdev1 root]# ./test_odbc.pl

Unable for connect to server at ./test_odbc.pl line 7.



I have been playing around with different perl scripts for a while now
but haven't had any success yet. I would really appreciate if anyone
else has some ideas. Thanks!



Scott K

_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds




Archive powered by MHonArc 2.6.24.

Top of Page