小编Tod*_*odd的帖子

通过SqlConnection/SqlCeConnection连接到.sdf数据库的问题

我在连接到.sdf(sql compact edition)数据库时遇到了极大的麻烦.我最初可以连接以提取行以验证用户名/密码,但是当我尝试通过SqlCeConnection/SqlCeCommand命令或通过尝试添加项SqlClient/SqlCommand连接向数据库添加项时,我没有运气.我明白了:

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)
Run Code Online (Sandbox Code Playgroud)

使用时:

private void button1_Click_1(object sender, EventArgs e)
{
    System.Data.SqlClient.SqlConnection sqlConnection1 =
    new System.Data.SqlClient.SqlConnection("Data Source=C:\\Users\\Tim\\Documents\\Visual Studio 2010\\Projects\\Dispatch POS\\Dispatch POS\\GhsDB.sdf");

    System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
    cmd.CommandType = System.Data.CommandType.Text;
    cmd.CommandText …
Run Code Online (Sandbox Code Playgroud)

c# sql sql-server

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

sql ×1

sql-server ×1