0

我有一个网格视图。在此之下,我使用了一些参数,如@LHNoofOverdueEMI 和@LHDisbDate。我想通过大于或等于@LHNoofOverdueEMI 的值并等于来自@LHDisbDate 的任何月份或年份的特定日期值的值进行查询。以下都是详细信息:

页面.aspx

<asp:SqlDataSource ID="DSGVRecList" runat="server" 
ConnectionString="<%$ ConnectionStrings:OptimaWebCustomerQueryCon %>" 
SelectCommand="select LHID, LHAcNo, LhAcName, LHIntRate, LHDisbDate
LHDrawingPower, LHtotalDisbAmt, LHEMI, LHNoofOverdueEMI,  LHUploadDate
from dbo.TblLoanHistory where
(YEAR(LHUploadDate) = YEAR(GETDATE())) AND (MONTH(LHUploadDate) = MONTH(GETDATE())) 
AND LHNoofOverdueEMI ??? 
AND  LHDisbDate ??? "

onselecting="DSGVRecList_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="txtNoofOverDue" Name="LHNoofOverdueEMI" PropertyName="Text" /> 
<asp:ControlParameter ControlID="txtEMIDate" Name="LHDisbDate" PropertyName="Text" />  
</SelectParameters>
</asp:SqlDataSource>

C#

protected void DSGVRecList_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
if (txtEMIDate.Text.Length == 0) e.Command.Parameters["@LHDisbDate"].Value = "%";
else e.Command.Parameters["@LHDisbDate"].Value = txtEMIDate.Text;
if (txtNoofOverDue.Text.Length == 0) e.Command.Parameters["@LHNoofOverdueEMI"].Value = "%";
else e.Command.Parameters["@LHNoofOverdueEMI"].Value = txtNoofOverDue.Text;
}
4

1 回答 1

1

您是否尝试过使用: SELECT DATEPART(weekday,GetDate()) ?

它根据指定的日期返回星期几。1 = 星期日,7 = 星期六。

于 2013-10-30T12:37:38.893 回答