Click here to Skip to main content
15,887,376 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I uninstall my old SQLserver and Install new sql server 2012 Now i add My old Database in my sql server 2012 and then i Connect this old database in my C# project An Error is occurred.
Infect I make a new database and make new C# project and then connect it it work good. but my not work with my OLD Database
Please help me how i remove this error.
This Error is occurred
System.Data.SqlClient.SqlException: '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)'


What I have tried:

its my connection string class.
namespace CNG
{
   public class dbconfig
    {
        public static string connectDb()
        {
            string conString = @" Data Source = CTRLSOFT - ELDHL3\SQLEXPRESS; Initial Catalog = CNG; Integrated Security = True";
            return conString;
        }
    }
}
Posted
Updated 17-May-18 6:12am
Comments
F-ES Sitecore 17-May-18 9:22am    
Make sure the connection string matches the server. We don't know what your servers are called, what your databases are called, what instance names you have given your servers so we can't do any of that for you. The issue might be the spaces in the hostname.
Fahid Zahoor 17-May-18 14:22pm    
its my server name.
CTRLSOFT-ELDHL3\SQLEXPRESS
its my Databse Name.
CNG

1 solution

I think the problem is in the String...
Verify the strings like
server name, database name
 
Share this answer
 
Comments
Fahid Zahoor 17-May-18 14:19pm    
i verify already server name and database name is same.

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