Visual Studio 2008中(C#)使用SQL精简版数据库错误:26 [英] Visual Studio 2008 (C#) with SQL Compact Edition database error: 26

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

问题描述

一个网络相关的或同时建立了
连接到SQL Server时发生特定实例的
错误。服务器
未找到或无法访问。
验证实例名称为
正确,以及SQL Server是
配置为允许远程
连接。 (provider: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();
}



连接字符串

the connection string is

数据源= | DataDirectory目录| \Database.sdf

Data Source=|DataDirectory|\Database.sdf

我难倒,任何洞察力?

推荐答案

您使用了错误的连接类型的对象。 SqlConnection的是长大了SQL服务器,而不是为SQL Server精简。

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精简版数据库错误:26的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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