我有一个用户id、密码、数据库名称和数据源详细信息。我想用Perl连接到MSSQL服务器。我只是使用了下面的片段,但我得到了一个错误。
#!/usr/bin/perl -w
use strict;
use DBI;
my $data_source = q/dbi:ODBC:192.168.3.137/;
my $user = q/bharani/;
my $password = q/123456/;
# Connect to the data source and get a handle for that connection.
my $dbh = DBI->connect($data_source, $user, $password)
or die "Can t connect to $data_source: $DBI::errstr";
我的错误是:
DBI connect( 192.168.3.137 , bharani ,...) failed: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002) at my sqlconnect.pl line 14
Can t connect to dbi:ODBC:192.168.3.137: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002) at mysqlconnect.pl line 14.
SQL服务器运行在另一个系统上,我只是想连接到上面的详细信息。请告诉我,我应该在我的系统中增加DSN,还是我的程序中缺少什么?