Dim datable As New DataTable
Dim d As Integer
d = DateDiff(DateInterval.Day, DateTimePicker1.Value, DateTimePicker2.Value)
m_dal.ConnectionOpen()
Dim sql As String
sql = "select * from 生产信息 where 1=1"
If DateTimePicker1.Value > DateTimePicker2.Value And d < 32 Then
sql += "and where 日期 between DateTimePicker1.Value and DateTimePicker2.Value"
End If
If Me.ComboBox1.Text <> "" Then
sql += "and 班别 like'" & Me.ComboBox1.Text & "'"
End If
If Me.ComboBox2.Text <> "" Then
sql += "and 班组 like'" & Me.ComboBox2.Text & "'"
End If
以上代码查询某日期范围无效,班别及班组查询ok,请帮忙看看。
------解决方案--------------------
断点能到
If DateTimePicker1.Value > DateTimePicker2.Value And d < 32 Then
sql += "and where 日期 between DateTimePicker1.Value and DateTimePicker2.Value"
这里面吗?如果进去了的话还查不出来。则改成这样试试 ‘"+DateTimePicker1.Value+"' and ‘"+DateTimePicker2.Value+"'
------解决方案--------------------
If DateTimePicker1.Value > DateTimePicker2.Value And d < 32 Then
sql += "and where 日期 between DateTimePicker1.Value and DateTimePicker2.Value"
End If
If DateTimePicker1.Value < DateTimePicker2.Value And d < 32 Then
日期大的,放在后面
------解决方案--------------------
WHERE (日期 BETWEEN '2007-01-06' AND '2007-01-07') 日期格式还跟后面的格式一致 yyyy-MM-dd