WEB开发网
开发学院软件开发C语言 c# 如何在类库里面共用连接 阅读

c# 如何在类库里面共用连接

 2009-03-13 08:19:11 来源:WEB开发网   
核心提示:private SqlConnection MyConn() { string setting = System.Configuration.ConfigurationManager.ConnectionStrings["myConnectionString"].ToString(); SqlCon

private SqlConnection MyConn()
    {
        string setting = System.Configuration.ConfigurationManager.ConnectionStrings["myConnectionString"].ToString();
        SqlConnection thisConn = new SqlConnection(setting);
        return thisConn;
    }

    public string req_title(int id)
    {
        SqlConnection QConn = MyConn();
        SqlDataAdapter myDap = new SqlDataAdapter("select article_title from t_article where art_id=" + id, QConn);
        DataSet myDS = new DataSet();
        myDap.Fill(myDS, "t_article");
        return (myDS.Tables[0].Rows[0][0].ToString());
    }

Tags:如何 里面 共用

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接