Visual Studio 2008(C#)与SQL Compact Edition数据库错误:26 [英] Visual Studio 2008 (C#) with SQL Compact Edition database error: 26

查看:217
本文介绍了Visual Studio 2008(C#)与SQL Compact Edition数据库错误:26的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


与SQL Server建立
连接时,发生网络相关或实例特定的
错误。找不到服务器
或无法访问。
验证实例名称是
正确,并且SQL Server是
配置为允许远程
连接。 (提供程序:SQL网络
接口,错误: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)

我创建了一个SQL压缩数据库,包含在我的应用程序,并可以连接到数据库罚款从其他数据库编辑器,但在我的应用程序中

I've created a SQL compact database, included it in my application, and can connect to the database fine from other database editors, but within my application im trying

using (SqlConnection con = new SqlConnection(Properties.Settings.Default.DatabaseConnection))
{
    con.Open();
}

连接字符串是


资料来源= | DataDirectory | \Database.sdf

Data Source=|DataDirectory|\Database.sdf

推荐答案

您使用的连接类型不正确。 SqlConnection用于成长的SQL服务器,不适用于SQL Server Compact。

You're using the wrong type of connection object. SqlConnection is for the grown up SQL server, not for SQL Server Compact.

connectionstrings.com 有您需要的连接字符串。对于连接对象本身,我相信你需要 SqlCeconnection

connectionstrings.com has the connection strings you need. For the connection object itself I believe you need the SqlCeconnection class

这篇关于Visual Studio 2008(C#)与SQL Compact Edition数据库错误:26的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆