1
votes

I'm working on a website using ASP.NET, C# and mssql. When I run the website on our local server it is working fine.

The following error occurs when I run it on a shared server:

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

I don't know how to play with connection string now since I'm very new to this.

1
Are you specifying a connection string in your Web.Config?Fred
yes am specifying my connection string in web.configPrhem
Take a look at this site connectionstrings.com/sql-server at a guess your server/data source setting is incorrect. some providers will give you an instance to connect to as well as the server. The link above will show you how to connect which ever way it is. It will be difficult for anyone to tell you exactly what is wrong unless you posted your connection string setting as you have it in your web config and the settings provided by your host.Fred

1 Answers

0
votes

It is recommend to keep the connection string in web.config. To create a valid connection string with SQL Server (either located on network or locally), use following steps:

Steps:

  1. Create a Test.UDL file at your desktop.
  2. Double click the file to see undermentioned Data Link Properties
  3. Select provider i.e SQL Server in your case
  4. Provide connection details i.e. server, username, password etc. in Connection tab.
  5. Test Connection on connection tab and press "OK".
  6. Open UDL file in notepad to see valid connection string.

enter image description here

UPDATE

check following link for creating UDL http://msdn.microsoft.com/en-us/library/e38h511e(v=vs.71).aspx

check following link for connection string Setting up connection string in ASP.NET to SQL SERVER