Only ASPX (HTML) file run through virtual directory but when connect to database it doesn't find web.config connection.My code..
<appSettings>
<add key="ugs" value="data source=192.168.0.235\SQLEXPRESS,80; Persist Security Info=True; initial catalog=ugs_academy; integrated security=true;" />
That is because you need to put the information in the connectionStrings element. Read more on MSDN
you can refer this link, how to get the value from AppSetttings and also you cand read an excellent article for appsettings AppSettings
string ConnStr= System.Configuration.ConfigurationManager.AppSettings["ugs"].ToString();
then later you pass this Connection string to your SqlConnection class open.
using(SqlConnection connObj = new SqlConnection(ConnStr))
{
//do some thing with ConnObj.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.