Error en la conexión a la base de datos
Frecuentes
Visto 285 veces
0
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();
El error es:
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)
Lo intenté SqlCeConnection
en lugar de SqlConnection
but, the compiler couldn't find the library with that class.
Por favor, ayude a resolver este problema.
- The OS : Windows 7
- Tool : Microsoft Visual Studio 2010
- Idioma: C #
1 Respuestas
5
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 compacto 4.0
- Agregar una referencia a
System.Data.SqlServerCe.dll
a tu proyecto - Add this using directive using
System.Data.SqlServerCe;
- Utilice las
SqlCeConnection
en lugar deSqlConnection
Respondido 28 ago 12, 11:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c# error-handling sql-server-ce database-connection or haz tu propia pregunta.
.sdf
is que probar definitivamente a SQL Server Edición compacta (CE) database - so you'll need to make sure you have the necessary assemblies installed in order forSqlCeConnection
to work. This will NO trabajar conSqlConnection
! - marc_sWhat assemblies do I need to install? - Nurlan
You need the SQL Server CE runtime stuff - check out Todo SQL Server Compact - this site has tons of explanations, tutorials, how-tos etc. and will definitely also have the info on what needs to be installed and where to get it from - marc_s