您的位置:首页 > 数据库

使用DateGridView显示表所有信息

2012-05-31 14:55 239 查看
 

获取视图ViewTBook的所有信息

/// <summary>
/// 获取所有信息
/// </summary>
/// <returns></returns>
public DataSet GetAllBook()
{
string sql = "select * from ViewTBook";
cmd.CommandText = sql;
DataSet myDS = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(myDS);
return myDS;
}


DateGridView显示代码

 因为上面代码写在BookDAL类里,所以这里要先实例

BookDAL bookdal = new BookDAL();
DataSet myDS = new DataSet();
myDS= bookdal.GetAllBook();
this.dataGridView1.DataSource = myDS.Tables[0].DefaultView;


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dataset sql string cmd
相关文章推荐