每当我运行Perl代码时,我都会遇到以下错误:
DBI connect('SQLSERVER','rti_dbuser',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002) at /usr/WINAST/RTI/AGI/M_TEST.pl line 14
Coudn't Connect SQL at /usr/WINAST/RTI/AGI/M_TEST.pl line 14.
配置文件如下:
ODBC.INI
[SQLSERVER]
description = Asterisk ODBC for SQL SERVER
;driver = FreeTDS
Driver = /usr/local/lib/libtdsodbc.so
server = 10.2.20.42\APSHCL
Database = RTI
port = 1433
tds_version = 9.0
try domain login = yes
try server login = yes
nt domain = DOMAIN
language = us_english
ODBCINST.INI
[FreeTDS]
Description = FreeTDS ODBC driver for MSSQL
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsS.so
FileUsage = 1
我的代码
use DBI;
use Data::Dumper;
use Asterisk::AGI;
my $agi = new Asterisk::AGI;
$first_param = $ARGV[0];
my $DSN = q/dbi:ODBC:SQLSERVER/;
my $uid = q/username/;
my $pwd = q/password/;
my $DRIVER = "Freetds";
my $dbh = DBI->connect($DSN,$uid,$pwd) or die "Coudn't Connect SQL";
my $servernumber = 2;
my $sql = "EXEC usp_check_black_list '".$first_param."'" ;
my $sth = $dbh->prepare($sql);
$sth->execute();
$return = $sth->fetchrow();
$agi->set_variable('result',$return);
print Dumper($return);
$sth->finish;
$dbh->disconnect;
每当我执行我的perl代码时,都找不到驱动程序。我已经定义了驱动程序,但它没有使用该驱动程序....
请帮帮我......
答案 0 :(得分:1)
尝试使用DBD :: Sybase。 MSSQL是Sybase代码的一个分支,尽管是YMMV,但DBD :: Sybase仍然运行良好。