c# - Entity Framework connection string - Error Locating Server/Instance Specified -


i'm facing issues trying connect sql server 2005 using entity framework.

i've small windowsform application using system.data.sqlclient.sqlconnection:

sqlconnection cnn = new sqlconnection("data source=servername\\sqlhotel;database=mydatabase;user id=myusername;password=mypassword");  try {     cnn.open();     messagebox.show ("connection open ");     cnn.close(); } catch (exception ex) {     messagebox.show("can not open connection ! "); } 

this working fine on server (i'm getting "connection open" message), in asp.net web api application using entity framework 6 i'm getting error using above connection string:

a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified)

why?

ensure tcp/ip enabled in sql server configuration manager, , sql server allowed through windows firewall (on server) if trying connect remotely. can add white list if not, security reasons bad idea - , bad idea if production server.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -