2013-10-30 13 views
0

我有一個網格視圖。在此之下,我使用了一些參數,如 @LHNoofOverdueEMI和@LHDisbDate。我想通過@LHNoofOverdueEMI的等於或等於 等於任意月份或年份的價值 來查詢@LHDisbDate的值。所有的詳情如下:由特定天asp.net c查詢#

page.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; 
} 
+0

這是什麼問題? – Zaki

回答

1

您是否嘗試過使用:SELECT DATEPART(平日,GETDATE())?

它返回基於指定日期的星期幾。 1 =星期日,7 =星期六。

+0

其實我想要任何一天查詢像1,4,10,23,27 –