问题
SQL Server Name : ECARE432
Instance Name : SQLEXPRESS
app.config
contains:
<connectionStrings>
<add name="TimeTracker.Properties.Settings.myecareConnectionString"
connectionString="Data Source=ECARE432;Initial Catalog=myecare;Persist Security Info=True;User ID=sa;Password=ecare123@"
providerName="System.Data.SqlClient"/>
</connectionStrings>
I have developed my first application in WPF (C#) with VS 2008 & SQL Server 2008. It works fine on my system. After deployment, it doesn't work on other systems.
It shows the following error message.
provider named pipes provider error 40 - could not open a connection to sql server 2008
I have gone through Google and done the following steps but no use.
- Configuration Tools -> SQL Server Configuration Manager -> SQL Native Client Configuration Aliases -> Alias Name -> ECARE432,1433, Port Number -> 1433, Protocol -> TCP/IP, Server Name -> ECARE432
- TCP/IP is enabled. Protocols -> TCP/IP Properties -> IP1 -> Active - Yes Enabled - Yes, IP Address - My system IP address, TCP Dynamic Ports - Blank, TCP Port - 1433
- IP2 -> Active - Yes, Enabled - Yes, IP Address - 127.0.0.1, TCP Dynamic Ports - Blank, TCP Port - 1433
- IPALL -> TCP Dynamic Ports - Blank, TCP Port - 1433
- SQL Server Browser is running.
- Server Name is correct. No typo mismatch.
- Client machine is able to ping my machine. (
PING ECARE432
is working) - TCP 1433 and UDP 1434 Exception added to Firewall. Also Turned off the Firewall in both my system and the client system.
sqlbrowser.exe
is added to the Firewall Exception List.- Allow Remote Connections enabled under Connections in SQL Server Properties.
- Visual Studio --> Tools --> Options --> Database Tools --> Data Connections --> Changed "SQL Server Instance Name" from
sqlexpress
to blank.
Please guide me how to fix this issue.
回答1:
If you have SQL Server Name: ECARE432
and Instance Name : SQLEXPRESS
- then you need to use ECASE432\SQLEXPRESS
as the value for your Data Source=
in your connection string:
<connectionStrings>
<add name="TimeTracker.Properties.Settings.myecareConnectionString"
connectionString="Data Source=ECARE432\SQLEXPRESS;Initial Catalog=myecare;Persist Security Info=True;User ID=sa;Password=ecare123@"
providerName="System.Data.SqlClient"/>
</connectionStrings>
Along the same lines - if your instance really is called SQLEXPRESS
- then why are you doing this??
Visual Studio --> Tools --> Options --> Database Tools --> Data Connections --> Changed "SQL Server Instance Name" from sqlexpress to blank.
Makes no sense at all. If the instance is in fact SQLEXPRESS
- let it be!
来源:https://stackoverflow.com/questions/16373181/provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-serv