Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]sql后台多条件查询问题

1楼
bigeng 发表于:2025/2/3 21:30:00
我用的多条件查询代码一直用的都是参照帮助里面的查询代码,但是会存在个问题,就是特别容易出现查询超时的情况,因此希望改成直接后台查询。但是上网查了一下,使用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
2楼
有点蓝 发表于:2025/2/4 9:51:00
上面的代码就已经是后台查询了呀。测试有什么问题?
3楼
bigeng 发表于:2025/2/4 10:53:00
就是特别容易出现查询超时的情况。
4楼
有点蓝 发表于:2025/2/4 11:10:00
那是数据库优化的问题。把条件里的列都添加到索引里
共4 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03809 s, 2 queries.