到目前为止,我已经编写了这段代码,它适用于我正在做的事情,但是如果我搜索 6 月 13 日,它只会查找到 6 月 12 日,有人可以帮我弄清楚我的代码有什么问题吗?或者我可以在哪里添加一天的间隔?我试过了,它只是不适合我。
var db = Database.Open("RMS") ;
var selectCommand = "SELECT * FROM RMS";
var formSSO = "";
var fromDate= "";
var toDate= "";
formSSO = Request.QueryString["formSSO"];
fromDate = Request.QueryString["fromDate"];
toDate = Request.QueryString["toDate"];
selectCommand = "(SELECT * from RMS WHERE SSO LIKE @0)";
if(!Request.QueryString["fromDate"].IsEmpty() ) {
selectCommand = "SELECT * FROM RMS WHERE SSO LIKE @0 AND Created BETWEEN @1 AND @2";
}
if(Request.QueryString["formSSO"].IsEmpty() ) {
<div class="simple"><strong>*SSO ID is Required.</strong></div>
}
var data = db.Query(selectCommand, formSSO, fromDate, toDate);
var columns = new[]{"ID", "SSO", "Category", "System", "Subject", "Created"};
var grid = new WebGrid(data, ajaxUpdateContainerId: "grid", defaultSort: "ID", columnNames: columns);
if (Request.QueryString[grid.SortDirectionFieldName].IsEmpty()) {
grid.SortDirection = SortDirection.Descending;
}
}