我通过Microsoft SQL Server管理工作室建立连接,允许我连接到具有服务器显示名称和用户名以及密码的群集数据库...
我试图将我的perl脚本连接到此数据库,但在我的IDE中继续收到此错误
DBI connect('ntcasdg3-db2\ntcafde4-db1','helping',...) failed:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002)
at C:/Users/harry/workspace/DataEx/DexDatabaseConnect.pl line 9 couldn't open database:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (SQL-IM002);
stopped at C:/Users/harry/workspace/DataEx/DexDatabaseConnect.pl line 9.
管理工作室是否使用其他方法连接到Perl中不可用的数据库?
这是我目前的代码:
#!c:\perl\bin\perl.exe -w
use DBI;
$db_user = "helping";
$db_pass = "helper";
$dsn_name= 'dbi:ODBC:ntcasdg3-db2\ntcafde4-db1';
my $dbh = DBI->connect($dsn_name, $db_user, $db_pass) or die "couldn't open database: $DBI::errstr; stopped";
my $sth = $dbh->prepare(<<End_SQL) or die "Couldn't prepare statement: $DBI::errstr; stopped";
SELECT vendor FROM dbo.dex_vendor_info
End_SQL
$sth->execute() or die "Couldn't execute statement: $DBI::errstr; stopped";