如何在 Windows 中使用 Perl 的 DBI 模块连接到 MSSQL 数据库?

2021-12-10 00:00:00 windows perl sql-server

如何在 Windows 中使用 Perl 的 DBI 模块连接到 MSSQL 数据库?

How do I connect to a MSSQL database using Perl's DBI module in Windows?

推荐答案

使用 DBD::ODBC.如果您只是使用控制面板 -> 系统管理 -> ODBC 数据源 -> 系统数据源或用户数据源创建数据源(这些是我记得的名称,但我的 XP 不是英文的,所以我无法检查),那么您所要做的就是在 DBI 连接字符串中使用该数据源的名称.

Use DBD::ODBC. If you just create a data source with the Control Panel -> System Management -> ODBC Data Sources -> System Data Source or User Data Source (those are the names as I remember them, but my XP isn't in English, so I can't check), then all you have to do is use the name of that data source in the DBI connect string.

my $dbh = DBI->connect("dbi:ODBC:$dsn", $user, $pwd, \%attr);

用户和系统数据源之间的区别在于后者可供任何用户使用.

The difference between User and System data source is that the latter is usable by any user.

另见:如何:在 Windows XP 中创建系统数据源名称

相关文章