Reputation: 2960
The following code gives an error during execution.
string connectionString = "Data Source=D:\\Base.sdf;Persist Security Info=False";
SqlConnection sqlConnection = new SqlConnection(connectionString))
sqlConnection.Open();
The error is:
A network-related or instance-specific error occured 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 not configured to allow remote connections. (provider:SQL network Interfaces, error: 26 - Error locating Server/Instance Specified)
I tried SqlCeConnection
instead of SqlConnection
but, the compiler couldn't find the library with that class.
Please, help to solve this problem.
Upvotes: 0
Views: 326
Reputation: 37858
Your database is a Sql Server compact edition one, you must use :
SqlCeConnection sqlConnection = new SqlCeConnection(connectionString);
Download the libs from here Microsoft SQL Server Compact 4.0
System.Data.SqlServerCe.dll
to your projectSystem.Data.SqlServerCe;
SqlCeConnection
instead of SqlConnection
Upvotes: 5