データベースからデータを表示しようとしました。今日いくつかのデータを保存した場合、それだけでGridView
.
週、月、年ごとに表示できるようにしたいと思います。
私のコード:
public void gettoday()
{
con.Open();
{
//string strview = "select MRNO,MaterialCode,Description,Specification,Category as Cat,Source as Sor,Population as Pop, StockInStores as Stock,MRRating as Rating,PreparedBy,PreparedDate,CheckedBy,CheckedDate,ApprovedBy,ApprovedDate from tbl_KKSMaterialRaise where PreparedDate between DateAdd(day,-1,GetDate()) AND DateAdd(day,+1,GetDate())";
string strview = "select MRNO,MaterialCode,Description,Specification,Category as Cat,Source as Sor,Population as Pop, StockInStores as Stock,MRRating as Rating,PreparedBy,PreparedDate,CheckedBy,CheckedDate,ApprovedBy,ApprovedDate from tbl_KKSMaterialRaise where PreparedDate between (getdate()-1) and (getdate()+1) order by PreparedDate";
SqlCommand cmd = new SqlCommand(strview, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
//SqlDataReader reader = cd.ExecuteReader();
}
else
{
GridView1.DataSource = null;
GridView1.DataBind();
}
}
con.Close();
}