使用SQL Native Client无法从Classic ASP连接到SQL Server 2008 R2(Windows 7 - IIS7)

时间:2021-06-13 01:44:41

I'm able to connect to SQL server 2008 R2 when I use Provider=SQLOLEDB in my connection string. But when I use Provider=SQLNCLI in connection string I'm unable to connect.

当我在连接字符串中使用Provider = SQLOLEDB时,我能够连接到SQL Server 2008 R2。但是当我在连接字符串中使用Provider = SQLNCLI时,我无法连接。

ADODB.Connection error '800a0e7a'

ADODB.Connection错误'800a0e7a'

Provider cannot be found. It may not be properly installed.

无法找到提供商。它可能没有正确安装。

/test.asp, line 7

/test.asp,第7行

Code written within test.asp is below

test.asp中编写的代码如下

<%
    Set cn = Server.CreateObject("ADODB.Connection")

    'Doesn't work
    cn.Open "Provider=SQLNCLI;Server=remoteServer\SQL2008R2;Database=DB;UID=MyUser;PWD=pa55word;"  

    'Works Perfectly
    'cn.Open "Provider=SQLOLEDB;Server=remoteServer\SQL2008R2;Database=DB;UID=MyUser;PWD=pa55word;" 

    cn.CommandTimeout = 900
    cn.Close
    Response.write("dfjslkfsl")
%>

The SQL Server I'm trying to connect (from classic ASP Page within my IIS 7 on windows 7) is located on different server in a different network to which I'm connecting using VPN.

我正在尝试连接的SQL Server(来自我在Windows 7上的IIS 7中的经典ASP页面)位于我使用VPN连接的不同网络中的不同服务器上。

I tested sql native client by creating a sql native client System DSN connection to the said Sql server 2008 R2 (which is connected through VPN) from ODBC datasource administrator. And it got connected successfully.

我通过从ODBC数据源管理员创建到所述Sql server 2008 R2(通过VPN连接)的sql本机客户端系统DSN连接来测试sql本机客户端。它成功连接。

These snaps are from my windows 7 system 使用SQL Native Client无法从Classic ASP连接到SQL Server 2008 R2(Windows 7  -  IIS7)

这些快照来自我的Windows 7系统

使用SQL Native Client无法从Classic ASP连接到SQL Server 2008 R2(Windows 7  -  IIS7)

使用SQL Native Client无法从Classic ASP连接到SQL Server 2008 R2(Windows 7  -  IIS7)

  • Windows 7
  • Windows 7的
  • IIS 7
  • IIS 7
  • Classic ASP page (.asp)
  • 经典ASP页面(.asp)

4 个解决方案

#1


15  

Try changing the provider to sqlncli10:

尝试将提供程序更改为sqlncli10:

cn.Open "Provider=SQLNCLI10;Server=remoteServer\SQL2008R2;Database=DB;UID=MyUser;PWD=pa55word;"

Maybe the name is differet on your machine. :)

也许你的机器名称不同。 :)

#2


4  

For users having only Visual Studio 2012 installed can use Provider=SQLNCLI11 as SQLNCLI10 is not available for me on my fresh installed system.

对于仅安装了Visual Studio 2012的用户,可以使用Provider = SQLNCLI11,因为在我刚安装的系统上,我无法使用SQLNCLI10。

cn.Open "Provider=SQLNCLI11;Server=remoteServer\SQL2008R2;Database=DB;UID=MyUser;PWD=pa55word;"

#3


0  

It could be related to the VPN fact. Maybe the app acts as a different user who doesn't have access to the VPN.

它可能与VPN事实有关。也许该应用程序充当不能访问VPN的不同用户。

Try to turn off anonymous Authentication in IIS and/or make the Application Pool identity be the same user you use to login to the Windows 7 machine and see if this fixes the problem.

尝试在IIS中关闭匿名身份验证和/或使应用程序池标识与您用于登录Windows 7计算机的用户相同,并查看是否可以解决问题。

#4


-2  

Works perfectly fine:

完美无缺:

"Provider=SQLNCLI;Server=xxxxxxxx;uid=sa;pwd=xxxxxx;database=xxxxxx;"

#1


15  

Try changing the provider to sqlncli10:

尝试将提供程序更改为sqlncli10:

cn.Open "Provider=SQLNCLI10;Server=remoteServer\SQL2008R2;Database=DB;UID=MyUser;PWD=pa55word;"

Maybe the name is differet on your machine. :)

也许你的机器名称不同。 :)

#2


4  

For users having only Visual Studio 2012 installed can use Provider=SQLNCLI11 as SQLNCLI10 is not available for me on my fresh installed system.

对于仅安装了Visual Studio 2012的用户,可以使用Provider = SQLNCLI11,因为在我刚安装的系统上,我无法使用SQLNCLI10。

cn.Open "Provider=SQLNCLI11;Server=remoteServer\SQL2008R2;Database=DB;UID=MyUser;PWD=pa55word;"

#3


0  

It could be related to the VPN fact. Maybe the app acts as a different user who doesn't have access to the VPN.

它可能与VPN事实有关。也许该应用程序充当不能访问VPN的不同用户。

Try to turn off anonymous Authentication in IIS and/or make the Application Pool identity be the same user you use to login to the Windows 7 machine and see if this fixes the problem.

尝试在IIS中关闭匿名身份验证和/或使应用程序池标识与您用于登录Windows 7计算机的用户相同,并查看是否可以解决问题。

#4


-2  

Works perfectly fine:

完美无缺:

"Provider=SQLNCLI;Server=xxxxxxxx;uid=sa;pwd=xxxxxx;database=xxxxxx;"