我正在开发一组针对SQL数据库的Web应用程序,以及一些用于处理数据的控制台应用程序。我的生产服务器和dev服务器都是Server2008 32位,不同之处在于dev服务器位于虚拟PC上并运行SqlExpress 2008.WebApp在虚拟PC上看到SQL数据库,但控制台应用不在
当前有问题的Web应用程序和控制台应用程序共享相同的连接设置。当设置指向生产时,Web和控制台应用程序都可以正常工作。当指向dev时,Web应用程序可以正常工作,但控制台应用程序无法连接(错误:40,下图)。两者之间有什么区别会导致这种行为?
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
虚拟PC通过Microsoft环回连接进行联网。当我切换到以太网连接时具有相同的行为。
PortQry将两个长相相似:
开发:
UDP port 1434 (ms-sql-m service): LISTENING or FILTERED
Sending SQL Server query to UDP port 1434...
Server's response:
ServerName DEV
InstanceName SQLEXPRESS
IsClustered No
Version 10.50.1600.1
tcp 49282
np \DEV\pipe\MSSQL$SQLEXPRESS\sql\query==== End of SQL Server query response ====
UDP port 1434 is LISTENING
生产:根据要求
UDP port 1434 (ms-sql-m service): LISTENING or FILTERED
Sending SQL Server query to UDP port 1434...
Server's response:
ServerName PRODUCTION
InstanceName MSSQLSERVER
IsClustered No
Version 9.00.4035.00
tcp 1433
np \PRODUCTION\pipe\sql\query==== End of SQL Server query response ====
UDP port 1434 is LISTENING
连接字符串:
<connectionStrings>
<add name="ProductionConnection" connectionString="Data Source=production.productiondomain.local;Initial Catalog=XXXXXXX;Persist Security Info=True;User ID=xxxx;Password=xxxx" providerName="System.Data.SqlClient"/>
<add name="DevConnection" connectionString="Data Source=dev\SQLEXPRESS;Initial Catalog=XXXXXXX;Persist Security Info=True;User ID=xxxx;Password=xxxx" providerName="System.Data.SqlClient"/>
</connectionStrings>
你可以发布你的连接字符串并用一些掩码字符替换敏感信息吗?可能的区别是用户帐户权限以及它们在环境与环境之间的差异。 – 2011-03-02 18:04:24