简体   繁体   English

指定协议和端口时,只能在ASP.NET 1.1中访问Sql Server 2005

[英]Sql Server 2005 only accessible in ASP.NET 1.1 when I specify protocol and port

My company is currently migrating some of their really old db's to sql server 2005. Some legacy apps have problems connecting to the new server. 我的公司目前正在将一些真正的旧数据库迁移到sql server2005。某些旧版应用程序在连接到新服务器时遇到问题。 The connection string works in Asp.NET 2.0, probably because it assumes tcp:1433 automatically. 连接字符串在Asp.NET 2.0中有效,可能是因为它自动假定tcp:1433。

I have to construct the connection string like this in ASP.NET 1.1 for it to work: 我必须在ASP.NET 1.1中构造这样的连接字符串才能使其工作:

"Server=tcp:my.server.com,1433;..."

Without the protocol and the port, the connection fails ("Invalid Connection exception") 没有协议和端口,连接将失败(“无效的连接异常”)

TCP 1433 and UDP 1434 are open on our firewall. 我们的防火墙已打开TCP 1433和UDP 1434。 On SQL Server 2005 Remote Access is enabled, so is TCPIP, the SQL Browser service is running, I use the proper login credentials. 在启用SQL Server 2005远程访问后,在启用TCPIP的同时,也在运行SQL Browser服务,我使用了正确的登录凭据。

Any ideas why I can't just specify the server name without protocol and port number? 有什么想法为什么我不能只指定没有协议和端口号的服务器名称?

IIRC SQL Server 2005 defaults to find any-old-port that is available. IIRC SQL Server 2005默认情况下会查找可用的任何旧端口。 On my laptop this means port 1212. 在我的笔记本电脑上,这意味着端口1212。

To force it to a specific port you must go to Start->Programs->SQL Server 2005->Configuration Tools->SQL Server Configuration Manager 要将其强制到特定端口,必须转到“开始”->“程序”->“ SQL Server 2005”->“配置工具”->“ SQL Server配置管理器”

From here you must go to SQL Server 2005 Network Configuration->Protocols for (name of service)->Right click on TCP/IP->Properties->Choose tab "IP Address" and set TCP Dynamic Ports to . 从这里,您必须转到SQL Server 2005网络配置->(服务名称)的协议->右键单击TCP / IP->属性->选择选项卡“ IP地址”,然后将TCP动态端口设置为。

For some reason "0" means "Yes, use dynamic ports" and (ie no entry in field) menas "No, I will specify it myself" 由于某些原因,“ 0”表示“是,请使用动态端口”,并且(即,在字段中没有输入)菜单项“否,我将自己指定”

Then fill in the field TCP Port with 1433. 然后在“ TCP端口”字段中填写1433。

Do so on all adapters that are listed, and restart the SQL Service. 在列出的所有适配器上执行此操作,然后重新启动SQL Service。

You can now check if the service is indeed on the right port by doing the following 现在,您可以通过执行以下操作来检查服务是否确实在正确的端口上

Start->Run->cmd.exe 开始->运行-> cmd.exe

C:>netstat -ano C:> netstat -ano

look for an entry like this 寻找这样的条目

 local address         <stuff>           PID
 0.0.0.0:1433                            <some number>

Now do C:>tasklist 现在执行C:> tasklist

and look for the task with the number from above. 并从上面查找带有数字的任务。 This task should be called something like sqlsrvr.exe. 该任务的名称应类似于sqlsrvr.exe。

Perhaps your SQL Server is configured for multi-protocol, and it's trying to use the other protocol first and failing, perhaps for some security reason (the account that the app is running as in IIS). 可能您的SQL Server配置为使用多协议,并且它正尝试首先使用其他协议而失败,也许出于某种安全原因(该应用程序在IIS中运行的帐户)。 Just a guess. 只是一个猜测。

Check the "SQL Native Client Configuration" settings in "SQL Configuration Manager" on the ASP.NET machine. 检查ASP.NET计算机上“ SQL配置管理器”中的“ SQL本机客户端配置”设置。 The default connection settings are set there. 在此设置默认的连接设置。 Also try messing with the MDAC configuration: 也可以尝试弄乱MDAC配置:

http://msdn.microsoft.com/en-us/library/ms131035.aspx http://msdn.microsoft.com/en-us/library/ms131035.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM