Click here to Skip to main content
15,614,685 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)

how can i clear this error please help me out
Updated 24-Dec-13 7:13am
Karthik_Mahalingam 24-Dec-13 21:49pm    
post your connection string.

The error is self explanatory. Check the credentials used. the ip address is if its remote as well as the port number. First try to manually test the connection through MS Sql Client/or server which ever you use . Once its successful , the same credentials can be used in the config connection string.
Share this answer
Basically, when you failed to connect to your SQL Server, the issue could be:
1) Network issue,
2) SQL Server configuration issue.
3) Firewall issue,
4) Client driver issue,
5) Application configuration issue.
6) Authentication and logon issue.
Check these
Steps to troubleshoot SQL connectivity issues[^]
SQL Server 2005 Connectivity Issue Troubleshoot - Part I[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part II[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part III[^]
Share this answer
in web.config page

    <add name="mycon" connectionString="data source=Data Source=.\SQLEXPRESS;AttachDbFilename=D:\sponsorship project\sponsorship.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
    <compilation debug="true" targetFramework="4.0"/>
    <authentication mode="Forms">

and in aspx page

protected void Button1_Click(object sender, EventArgs e)
       string connect = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;

       SqlConnection con = new SqlConnection(connect);
       cmd.Connection = con;
Share this answer
First of all why you not share your connection string in question?

Sql Connection string in Windows Authentication. you can change as you want. like that
SqlConnection con= new SqlConnection("Data Source=your User Name or you can try .[dot];Initial Catalog=Database Name;Integrated" Security=True;Pooling=False");

Sql Server Authentication.


  <add name="MyDbConn">
       connectionString="Server=MyServer; Database=pubs; User Id=MyUser; password= P@ssw0rd"
       providerName="System.Data.SqlClient" />

for more information hit this link

any query hit to reply.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900