以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]如何实现在分页表中的查询 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=40171) |
-- 作者:foskycn -- 发布时间:2013/9/11 11:22:00 -- [求助]如何实现在分页表中的查询 查询按钮: Dim Filter As String With e.Form.Controls("物料编码") If .Value IsNot Nothing Then Filter = "物料编码 like \'*" & .Value & "*\'" End If End With With e.Form.Controls("供应商") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "供应商 = \'" & .Value & "\'" End If End With Tables("物料表").Filter = filter 物料表是采用帮助里面的分布加载树设计的,这样每次查询都只是当前页的内容,代码如何写才能实现在全部页中查找需要的内容?请老师指导! AFTERLOAD代码: Dim dt As DataTable cmd.C cmd.CommandText = "SELECT DISTINCT 大类,中类,供应商 From {物料表}" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt,"大类|中类|供应商") trv.Nodes.Insert("加载所有数据",0) \'加载第一页数据 With DataTables("物料表") .LoadFilter = "" \'清除加载条件 .LoadPage = 0 \'加载第一页 .LoadTop = 25 \'每页25行 .Load() e.Form.Controls("TextBox1").Value = 1 & "/" & .TotalPages End With |
-- 作者:Bin -- 发布时间:2013/9/11 11:23:00 -- 不要设置FIlter 设置LoadFilter 然后重新Load一次. |
-- 作者:foskycn -- 发布时间:2013/9/11 11:30:00 -- If Filter > "" Then Dim cmd As New SQLCommand Dim dt As DataTable cmd.C cmd.CommandText = "SELECT DISTINCT 大类,中类,供应商 From {物料信息表}" dt = cmd.ExecuteReader() dt.LoadFilter = Filter dt.load() End If 这样子也试过,毫无反应 |
-- 作者:Bin -- 发布时间:2013/9/11 11:32:00 -- 你这个是什么意思? 看不懂啊.你这样做的意义是什么? 我的意思是让你设置DataTables("物料表").LoadFIlter 然后再LOAD
|
-- 作者:foskycn -- 发布时间:2013/9/11 14:36:00 -- Dim Filter As String With e.Form.Controls("物料编码") If .Value IsNot Nothing Then Filter = "物料编码 like \'*" & .Value & "*\'" End If End With With e.Form.Controls("供应商") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "供应商 = \'" & .Value & "\'" End If End With With e.Form.Controls("物料名称") 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("规格型号") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "规格型号 like \'*" & .Value & "*\'" End If End With If Filter > "" Then DataTables("物料信息表").LoadFilter = filter DataTables("物料信息表").load() End If 之前本来是这样子的,得到的结果是空 删了一些条件之后还是不行,是不是filter的表达不能这样写? 用tables(XXX).filter=filter来查询的话上面的表达式是成立的 |
-- 作者:狐狸爸爸 -- 发布时间:2013/9/11 14:40:00 -- 纸上不谈兵,用例子说话。 |
-- 作者:foskycn -- 发布时间:2013/9/11 14:55:00 -- 例子上来了: 知道了,下次一定先上例子!
[此贴子已经被作者于2013-9-11 14:55:38编辑过]
|
-- 作者:狐狸爸爸 -- 发布时间:2013/9/11 15:12:00 -- Dim Filter As String With e.Form.Controls("物料编码") If .Value IsNot Nothing Then Filter = "物料编码 like \'%" & .Value & "%\'" End If End With With e.Form.Controls("供应商") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "供应商 = \'" & .Value & "\'" End If End With With e.Form.Controls("物料名称") 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("规格型号") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "规格型号 like \'%" & .Value & "%\'" End If End With If filter > "" Then DataTables("物料信息表").LoadFilter = Filter DataTables("物料信息表").load() End If |
-- 作者:foskycn -- 发布时间:2013/9/11 15:34:00 -- 原来是如此,谢谢狐爸!! |