当用户选择日期时,我使用SqlDataSource控件列出搜索结果,但如果日期为null,则会列出所有记录。如何做sql命令?
SELECT Ref_No as name, Job_Order_ID as value
FROM Job_Order
WHERE (Status <> 'JO_Completed') AND (Delivery_Date = @jaDate)
OR (Status <> 'JO_Completed') ORDER BY Ref_No
生成下拉列表的代码
<asp:SqlDataSource ID="NewJobOrderDS" runat="server" SelectCommand="SELECT Ref_No as name, Job_Order_ID as value FROM Job_Order WHERE (Status <> 'JO_Completed') AND (Delivery_Date = @jaDate) ORDER BY Ref_No" OnSelecting="NewJobOrderDS_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="txtJADate2" Name="jaDate" PropertyName="Text" Type="DateTime"/>
</SelectParameters>
</asp:SqlDataSource>