SQL Compact 2008连接字符串问题

编程入门 行业动态 更新时间:2024-10-28 08:30:42
本文介绍了SQL Compact 2008连接字符串问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下代码连接到sql server精简版2008:

I have the following code to connect to a sql server compact edition 2008:

private SqlConnection sqlConn; public void createConnection() { String connectionString = @"Data Source=C:\Projects\somefile.sdf;Persist Security Info=False"; sqlConn = new SqlConnection(connectionString); sqlConn.Open(); }

但是,当 sqlConn时,我不断收到以下错误消息.open()被执行:

与网络相关或与实例相关的错误建立与SQL 服务器的连接时发生。找不到服务器或无法访问。验证实例名称正确并且SQL 服务器配置为允许远程连接。(提供者:SQL Network 接口,错误:26-错误定位指定的服务器/实例)

"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)"

是否有人知道问题可能是什么?我可以在数据库浏览器中创建到db的连接,但似乎无法在代码中使用。

Does anyone have any ideas what the problem might be? I can create a connection to the db in the database explorer but it doesn't seem to work in code.

推荐答案

System.Data.SqlClient 中的code> Sql * 类只能用于连接到常规SQL Server实例。

The Sql* classes in System.Data.SqlClient can only be used to connect to a regular SQL Server instance.

要连接到SQL CE数据库,您需要创建一个 System.Data.SqlServerCe.dll

To connect to a SQL CE database, you need to create a SqlCeConnection object in System.Data.SqlServerCe.dll.

更多推荐

SQL Compact 2008连接字符串问题

本文发布于:2023-10-28 13:09:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536722.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   SQL   Compact

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!