我正在通过使用SQL Server 2008作为数据库服务器的C#.net中的Windows应用程序。以下是我的app.config文件中的代码:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="myconnection" value="Data Source=ritesh-pc\SQLEXPRESS;Initial Catalog=dbname;Integrated Security=SSPI"/>
</appSettings>
</configuration>
每当我尝试访问该密钥时
"myconnection" as string connectionString = ConfigurationSettings.AppSettings["myconnection"];
发生以下错误
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)
最佳答案
这可能是由于密码/等原因导致您的连接字符串错误/无法访问。