使用日期时间选择器进行范围搜索 [英] Range searching using date time picker
问题描述
我很擅长编码,如果你们可以帮我解决这个问题,试图在两个日期之间进行搜索,即从日期到到日期,并在网格视图中显示结果,我将不胜感激。
我尝试过:
我目前正在使用此代码
Me.GBCPVRBindingSource.Filter =RECORDING DATE> ='& DateTimePicker1.Text& '和RECORDING DATE< ='& DateTimePicker2.Text& 。但是我得到的错误显示了这个 - 在'Date'操作符之后缺少操作数。
有人可以帮我解决这个问题,并把它弄好。
谢谢
Am new to coding and would be grateful if you guys can help me to solve this issue to trying to search between two dates ie "From Date" to "To Date" and display the results in Grid View.
What I have tried:
I am currently using this code
Me.GBCPVRBindingSource.Filter = "RECORDING DATE >= "’ & DateTimePicker1.Text & "’ and RECORDING DATE <= "’ & DateTimePicker2.Text & "’". But the error i get shows this - "missing operand after 'Date' operator.
Can someone please help me with this code and get it right.
Thanks
推荐答案
我注意到列名称
RECORDING DATE
中有空格,换行它们在方括号中如下:
, wrap them in square brackets like this:
[RECORDING DATE]
。
接下来,是你的datetimepickers的单引号,它们没有正确嵌套,
.
Next, is the single quote for your datetimepickers, they are not nested correctly,
"’ & DateTimePicker1.Text & "’
它应该是
'" & DateTimePicker1.Text & "’
与datetimepicker2相同
最后,而不是
same for datetimepicker2
Lastly, instead of
DateTimePicker1.Text
它应该更合适
DateTimePicker1.Value.ToString()
学习 DateTimePicker.Value属性 [ ^ ] vs DateTimePicker.Text属性 [ ^ ]
Learn DateTimePicker.Value Property[^] vs DateTimePicker.Text Property[^]
这篇关于使用日期时间选择器进行范围搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!