Comparing DateTime values in SelectCommand
I am working on ASP.net application with a MS Access database.I want to only display those list of entries whose DateTime value is greater than the present date and time. I am having difficulty in comparing in SelectCommand, as to how to pass the datetime parameter. My code is as follows: `
SelectCommand="SELECT `ID`, `eventname`, `description`, `venue`, `coordinator`, `time` FROM `upcoming` ORDER BY `time` WHERE (`time`>=?)"
UpdateCommand="UPDATE `upcoming` SET `eventname` = ?, `description` = ?, `venue` = ?, `coordinator` = ?, `time` = ? WHERE `ID` = ?">
<UpdateParameters>
<asp:Parameter Name="eventname" Type="String" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="venue" Type="String" />
<asp:Parameter Name="coordinator" Type="String" />
<开发者_运维问答asp:Parameter Name="time" Type="DateTime" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:Parameter Name="time" Type="DateTime" PropertyName="Text" />
</SelectParameters>
</asp:AccessDataSource>`
Please tell me how can i pass the datetime value to the SelectParameters through this code. Thank You for looking in it.
you should use
SELECT ID, eventname, description, venue, coordinator, [time]
FROM upcoming
WHERE time > NOW()
ORDER BY time
NOW()
is a builtin function in Access, so you don't need to pass it to the query
精彩评论