请问在asp.net中,resource.GetString(),config集合,settings集合怎么使用

解决方案 »

  1.   

    <appSettings>

    <add key="ConnSql" value="server=localhost;database=study;uid=sa;pwd=sa"></add>

    </appSettings>
    -----------------------
    下面是使用.
    /// <summary>
    /// 打开数据库
    /// </summary>
    public void Open()
    {
    if (conn==null)
    {
    //System.Web.HttpContext.Current.Response.Write("<BR>CONN IS NULL ,CREATE A NEW CONN2");
    conn= new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnSql"]);
    }
    try
    {
    if(conn.State==System.Data.ConnectionState.Closed)
    {
    //System.Web.HttpContext.Current.Response.Write("<BR>CONN IS CLOSED2");
    conn.Open();
    }
    }
    catch(SqlException Ex)
    {
    //System.Web.HttpContext.Current.Response.Write("<br>err:"+Ex.Message.ToString());
    System.Web.HttpContext.Current.Response.End();
    // page.Response.Write ("err:"+Ex.Message.ToString());
    // page.Response.End();
    }
    finally
    {
    //System.Web.HttpContext.Current.Response.End();
    }
    }