0

私はグリッドビューを持っています。この下で、@LHNoofOverdueEMI や @LHDisbDate などのパラメーターを使用しました。@LHNoofOverdueEMI の値以上で、@LHDisbDate の任意の月または年の特定の日の値と等しい値でクエリを実行したいと考えています。詳細は以下のとおりです。

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;
}
4

1 に答える 1

1

使用してみました: SELECT DATEPART(weekday,GetDate()) ?

指定された日付に基づいて曜日を返します。1 = 日曜日、7 = 土曜日。

于 2013-10-30T12:37:38.893 に答える