【发布时间】:2013-01-28 13:48:40
【问题描述】:
我刚刚知道基于服务的数据库和本地数据库之间的差异,因此根据我的需要,我已将项目数据库转移到本地数据库,我质疑并发现我只需要替换主要的连接字符串里面的东西,我不需要在我的代码中添加和替换。现在我收到了我不知道如何解决的错误 我的本地数据库代码是
SqlConnection con = new SqlConnection();
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"Data Source=E
:\project\+project\WindowsFormsApplication1\Database1.sdf";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
conn.Open();
try
{
// something
}
catch (Exception)
{
MessageBox.Show("ERROR");
}
conn.Close();
}
我在 conn.open 上遇到错误
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)
【问题讨论】:
标签: c# sql-server