获取视图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;