我用的多条件查询代码一直用的都是参照帮助里面的查询代码,但是会存在个问题,就是特别容易出现查询超时的情况,因此希望改成直接后台查询。但是上网查了一下,使用sql进行多条件查询,涉及到动态拼接等情况,看的我云里雾里的,也没有看懂,因此,希望各位大佬给看一下,如何将下面的查询改成直接后台查询的情况(数据库为sql server2008)。Dim Filter As String
With e.Form.Controls("SFLB")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "收发类别 like '%" & .Value & "%'"
End If
End With
With e.Form.Controls("HT")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "提货单号 like '%" & .Value & "%'"
End If
End With
With e.Form.Controls("StartDate")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "过磅日期 >= '" & .Value & "'"
End If
End With
With e.Form.Controls("EndDate")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "过磅日期 <= '" & .Value & "'"
End If
End With
if Filter > "" Then
DataTables("收货登记明细表").LoadFilter = Filter
DataTables("收货登记明细表").Load
End If