I am using the configurationmanager.appsetting
and I'm getting an error in the cn.Open
line.
The web form code is as follows:
public partial class admin_CheckDocuments : System.Web.UI.Page
{
SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["con"]);
string sql;
string str;
protected void Page_Load(object sender, EventArgs e)
{
cn.Open();
str = Request.QueryString["taxid"];
if (!IsPostBack)
{
filldata();
}
}
web.config
is:
<configuration>
<connectionStrings/>
<appSettings>
<add key="con"
value="Data Source=EGGG\SKDB;Initial Catalog=tax;Integrated Security=true"/>
</appSettings>
The error is
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)