积极答复者
三层架构dataset读取数据某一张表怎么读取数据

问题
-
1.DAL
public DataSet getInfUser(string sql) {
con.Open;
SqlDataAdapter sda = new SqlDataAdapter(sql,con);
DataSet ds = new DataSet();
sda.Fill(ds);
return ds;
}2.BLL
public string getInfBll() {
string sql = "select userName,userPwd,userMail from user_tb";
return uDAL.getInfUser(sql);
}
3.UI
protected void Page_Load(object sender, EventArgs e)
{
BLL.userBLL UB = new userBLL();
this.GridView1.DataSource = UB.getInfBll;
this.GridView1.DataBind();
}怎么写可以吗?好像不可以啊?如果要这样字写的话,需要怎么修改呢?
怎么用dataset读取数据库的某一张表的字段?
you are welcome
答案
-
你好
在這個情況你可以考慮使用DataTable
E.G.
改變DAL 便可
1.DAL
public DataTablegetInfUser(string sql) {
con.Open;
SqlDataAdapter sda = new SqlDataAdapter(sql,con);
DataTableds = new DataTable();
sda.Fill(ds);
return ds;或
可以 用 ds.Tables[0]; 或 ds.Tables["tablename"];
Please correct me if my concept is wrong
Chi- 已标记为答案 威尼斯三人 2011年2月19日 4:58
全部回复
-
你好
在這個情況你可以考慮使用DataTable
E.G.
改變DAL 便可
1.DAL
public DataTablegetInfUser(string sql) {
con.Open;
SqlDataAdapter sda = new SqlDataAdapter(sql,con);
DataTableds = new DataTable();
sda.Fill(ds);
return ds;或
可以 用 ds.Tables[0]; 或 ds.Tables["tablename"];
Please correct me if my concept is wrong
Chi- 已标记为答案 威尼斯三人 2011年2月19日 4:58