我想搜索两个日期之间的记录,但是此代码不起作用。
protected void BtnSearch_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
string ToDate = txtDateTo.Text;
string DateFrom = txtDateFrom.Text;
dt = NewLeadClass.GetReport(ToDate, DateFrom);
}
public static DataTable GetReport(string ToDate,string FromDate)
{
SqlParameter[] param = new SqlParameter[]
{
new SqlParameter("@ToDate", ToDate),
new SqlParameter("@FromDate",FromDate)
};
DataSet ds = SqlHelper.ExecuteDataset(Utility.GetConString(), CommandType.Text, "Select * from EmpDailyReport where RecordDate <= @ToDate and RecordDate>= @FromDate",param);
return ds.Tables[0];
}
将您的查询更改为:
DataSet ds = SqlHelper.ExecuteDataset(Utility.GetConString(), CommandType.Text, "Select * from EmpDailyReport where RecordDate BETWEEN @FromDate and @ToDate
changesdone here : "where RecordDate BETWEEN @FromDate and @ToDate "
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句