asp.net 数据集如何绑定到变量

来源:百度知道 编辑:UC知道 时间:2024/06/24 04:33:06
public DataTable AllLoing()
{
SqlConnection con = DB.DateZCFW();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select * from Login,con");
DataSet DsLogin = new DataSet();
sda.Fill(DsLogin, "Login");
return DsLogin.Tables["Login "];

}
建立了一个数据集,想绑定到变量上该怎么写?

public DataTable AllLoing(string sql,string TabelName)
{
SqlConnection con = DB.DateZCFW();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand(sql,con);
DataSet DsLogin = new DataSet();
sda.Fill(DsLogin, TableName)
return DsLogin.Tables[TableName];

}
DataTable dt=AllLoing("select * from Login","Login");
然后处理Datatable