WPF with local database application
I was about to start but I faced this problem
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 searched alot to found that the error will be in the connection string
but I’m using the connection string from application settings which done by the wizard
using ( SqlConnection _SqlConnection = new SqlConnection ( Properties . Settings . Default . DatabaseConnectionString ) )
{
_SqlConnection . Open ( ); // <= Error Occurs Here
_SqlConnection . Close ( );
}
Error :
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)
You’re using the wrong type of connection object.
SqlConnectionis for the grown up SQL server, not for SQL Server Compact. connectionstrings.com has the connection strings you need. For the connection object itself I believe you need theSqlCeConnectionclass (add a reference to System.Data.SqlServerCe).