Sql server 如何使用Win32::SqlServer进行远程连接?

Sql server 如何使用Win32::SqlServer进行远程连接?,sql-server,perl,winapi,Sql Server,Perl,Winapi,我无法使用Win32::SqlServer成功连接到我的SQLServer2005。服务器位于另一台计算机上。我正在使用最新版本的ActivePerl和模块 使用C中的ADO.NET提供程序,我可以使用连接字符串成功建立连接: 数据源=1.2.3.41553;初始目录=dbname;用户Id=用户名;密码=pw 为了将其转换为Perl,我尝试了以下步骤: my $conn = Win32::SqlServer::sql_init(); $conn->setloginproperty('C

我无法使用Win32::SqlServer成功连接到我的SQLServer2005。服务器位于另一台计算机上。我正在使用最新版本的ActivePerl和模块

使用C中的ADO.NET提供程序,我可以使用连接字符串成功建立连接: 数据源=1.2.3.41553;初始目录=dbname;用户Id=用户名;密码=pw

为了将其转换为Perl,我尝试了以下步骤:

my $conn = Win32::SqlServer::sql_init();

$conn->setloginproperty('ConnectionString', 'Data Source=1.2.3.4,1553;Initial Catalog=dbname;User Id=username;Password=pw;');
print $conn->connect();
此外,我还尝试使用setloginproperty分别设置服务器、登录信息和初始数据库

这些都会在超时时间满足后失败,并显示消息:

SQL Server message 2, Severity 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Message 08001 from 'Microsoft SQL Native Client', Severity: 16
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
Message HYT00 from 'Microsoft SQL Native Client', Severity: 16
Login timeout expired
Terminating on fatal error at mkadm.pl line 54

早期示例失败的原因是sql_init方法需要传入参数。 为了使用setloginproperty注入设置,应使用-->new创建未初始化的SqlServer对象