如何在 Windows 中使用 Perl 的 DBI 模块连接到 MSSQL 数据库? [英] How do I connect to a MSSQL database using Perl's DBI module in Windows?

查看:44
本文介绍了如何在 Windows 中使用 Perl 的 DBI 模块连接到 MSSQL 数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 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 中创建系统数据源名称

这篇关于如何在 Windows 中使用 Perl 的 DBI 模块连接到 MSSQL 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆