简体   繁体   中英

Error 26: Error Locating Server/Instance Specified in production environment - SQL server 2014 wpf wcf

I realise that this problem has been raised many times and a number of suggestions for how to fix it have been made, but despite following many of these suggestions, including all the one's listed here: How to solve Error 26: Error Locating Server/Instance Specified in production environment?

and here: http://blogs.msdn.com/b/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx

and turning the firewall off I still can't resolve my problem. I have a WCF service that I am running via Visual Studio Express 2012 for Web. The service talks to a database I have set up in SQL Server Management studio. The server, database and service are all running locally on a windows 8 laptop. I connect the to service via a WPF application on the same laptop. This is a development version hence running it all on the laptop. This works fine on one laptop but when I transfer everything over to another laptop I get the error: 26 issue. Both laptops are the same (same make/model/spec/OS).

The machine that works has the following connection string (where laptop-name is the name of my laptop and DBname is the name of the database):

<add name="AirportTaxiAccountsPackageDBConnectionString" connectionString="Data Source=laptop-name\SQLEXPRESS;Initial Catalog=DBname;Integrated Security=True"
  providerName="System.Data.SqlClient" />

NB:the set up details within SQL server management studio are: server name is laptop-name\\SQLEXPRESS and the connection is laptop-name\\user-nameA

The machine that doesn't work has the following connection string:

<add name="AirportTaxiAccountsPackageDBConnectionString" connectionString="Data Source=laptop-name\SQLEXPRESS;Initial Catalog=DBname;Integrated Security=True"
  providerName="System.Data.SqlClient" />

NB: the set up details within SQL server management studio on this computer are: server-name is laptop-name\\SQLEXPRESS and the connection is laptop-name\\user-nameB

This connection string was set up on the second laptop by creating and testing the connection from within VS via the database connection wizard. when I test the connection via the wizard it works fine, it's only when I connect to it via my wpf application that a connection problem occurs.

One last thing, I checked the service is runnning correctly on the second laptop, it is fine and I can connect to it, the problem occurs when I try to access the database. the process is run service using host, connect to service via WPF, connect to database > error 26

Any ideas?

Edited again i've set up a test client which can access the service, I get the same error which is the error 26 error locating server/instance specified

RESOLVED I was hard coding the database configuration details again via a class within the service rather than talking to the configuration file!! I am a dufus but now I know better :)

我已经硬编码数据库连接字符串到配置类这是覆盖数据库连接字符串中的app.config文件腮红服务中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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