i am defining the connection string in 2 methods,
the first which works fine is like that
private void Button_Click(object sender, System.EventArgs e)
{
CommonFunction myObject;
SqlConnection myConnection= new SqlConnection("server=(local)\\NetSDK;database=kach;uid=webapp;pwd=1234");
myConnection.Open()
}
the second one is by using the web.config so that i should just define it in just one page(web.config)
private void Button_Click(object sender, System.EventArgs e)
{
string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"];
SqlConnection myConnection = new SqlConnection(connectionInfo);
myConnection.Open()
}
and i have define the connectionstring in web.config like this
<appSettings>
<add key="ConnectionInfo" value="server=(local)\\NetSDK;database=kach;uid=webapp;pwd=1234" />
</appSettings>
but in second method it says that sql server doesn't exist or access denied, the information (userId,password,database) are the same , so why does this happen?
the first which works fine is like that
private void Button_Click(object sender, System.EventArgs e)
{
CommonFunction myObject;
SqlConnection myConnection= new SqlConnection("server=(local)\\NetSDK;database=kach;uid=webapp;pwd=1234");
myConnection.Open()
}
the second one is by using the web.config so that i should just define it in just one page(web.config)
private void Button_Click(object sender, System.EventArgs e)
{
string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"];
SqlConnection myConnection = new SqlConnection(connectionInfo);
myConnection.Open()
}
and i have define the connectionstring in web.config like this
<appSettings>
<add key="ConnectionInfo" value="server=(local)\\NetSDK;database=kach;uid=webapp;pwd=1234" />
</appSettings>
but in second method it says that sql server doesn't exist or access denied, the information (userId,password,database) are the same , so why does this happen?