Selecting rows from Access database by date search criteria in VB.NET form

我是研究僧i 提交于 2019-12-02 07:18:21

What could be the issue with this is the string format. I'm not sure if Access will convert the string to a Date and then compare or convert the Date to a string and then compare. You can try this:

Format(Orders.OrderDate,'mm/dd/yyyy') >= Format(#" + startDate.Value.Date + "#,'mm/dd/yyyy')

Or you could always just use the date directly,

OrderDate >= #" + startDate.Value.Date + "#"

Edit:, to do my due diligence, you really should be doing the query like this

OrderDate >= @StartDate

Then add this code

adapter.Parameters.Add("@StartDate", startDate.Value.Date);

Using parameters is important for robust code and to avoid the dreaded SQL injection attack.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!