问题描述
当我在连接字符串中使用 Provider = SQLOLEDB
时,我可以连接到SQL Server 2008 R2。但是当我在连接字符串中使用 Provider = SQLNCLI
时无法连接。
test.asp
中的代码位于
<%
Set cn = Server.CreateObject(ADODB.Connection)
'不工作
cn.OpenProvider = SQLNCLI; Server = remoteServer\\ \\ SQL2008R2; Database = DB; UID = MyUser; PWD = pa55word;
'完美的
'cn.OpenProvider = SQLOLEDB; Server = remoteServer\SQL2008R2; Database = DB; UID = MyUser; PWD = pa55word;
cn.CommandTimeout = 900
cn.Close
Response.write(dfjslkfsl)
%>
我试图连接的SQL Server(从我的IIS 7中的经典ASP页面在Windows 7 )位于使用VPN连接的不同网络中的不同服务器上。
我通过创建一个sql本地客户端测试sql本机客户端通过ODBC数据源管理员与所述Sql Server 2008 R2(通过VPN连接)进行系统DSN连接。它已成功连接。
这些快照来自我的Windows 7系统
- Windows 7
- IIS 7
- 经典ASP页面(.asp)
尝试将提供程序更改为 sqlncli10
:
cn.OpenProvider = SQLNCLI10; Server = remoteServer\SQL2008R2; = DB; UID = MyUser; PWD = pa55word;
也许在您的机器上名称不同。 :)
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.
Code written within test.asp
is below
<%
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.
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.
These snaps are from my windows 7 system
- Windows 7
- IIS 7
- Classic ASP page (.asp)
Try changing the provider to sqlncli10
:
cn.Open "Provider=SQLNCLI10;Server=remoteServer\SQL2008R2;Database=DB;UID=MyUser;PWD=pa55word;"
Maybe the name is differet on your machine. :)
这篇关于无法使用SQL Native Client从经典ASP连接到SQL Server 2008 R2(Windows 7 - IIS7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!