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

查看:58
本文介绍了如何在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天全站免登陆