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());
}
更多精彩
赞助商链接