几句asp.net代码,谁能帮忙解释下啊 本人初学 解释的清楚些啊

来源:百度知道 编辑:UC知道 时间:2024/07/07 23:54:28
string CONN_STRING_NON_DTC = System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["DateBaseConnectionString"]);
string strcon = @"Data Source=.\SQLEXPRESS;AttachDbFilename='" + CONN_STRING_NON_DTC + "';Integrated Security=True;User Instance=True";
SqlConnection con = new SqlConnection(strcon);

//String变量 CONN_STRING_NON_DTC

//获得路径(服务器上的物理路径,也就是常说的绝对路径)System.Web.HttpContext.Current.Server.MapPath

//读取Web.config中节点为DateBaseConnectionString的Value
ConfigurationManager.AppSettings["DateBaseConnectionString"]);

//数据库连接字符串
string strcon = @"Data Source=.\SQLEXPRESS;AttachDbFilename='" + CONN_STRING_NON_DTC + "';Integrated Security=True;User Instance=True";

//使用上面的连接字符串建立一个SqlConnection对象

SqlConnection con = new SqlConnection(strcon);

string CONN_STRING_NON_DTC = System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["DateBaseConnectionString"]);
这是从配置文件Web.config里面读取数据库的连接字符串的中一部分。。
string strcon = @"Data Source=.\SQLEXPRESS;AttachDbFilename='" + CONN_STRING_NON_DTC + "';Integrated Security=True;User Instance=True";
这一句就是把从配置文件里面读出来的东西拼装起来。。懂?