以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- TreeView 遍历所有子节点并实现多项目查询 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=100507) |
-- 作者:lanbor -- 发布时间:2017/5/12 16:38:00 -- TreeView 遍历所有子节点并实现多项目查询 问题如图片,就是不知道怎么写代码。 还希望专家指教一点点套路!
|
-- 作者:有点色 -- 发布时间:2017/5/12 16:55:00 -- 如果你的目录树已经生产,直接在 AfterSelectNode 写代码
Dim cs As String = "\'" & e.node.name & "\'," For Each nd As winform.treenode In e.node.AllNodes msgbox(cs) Tables("物料记录").Filter = "Category in (" & cs.trim(",") & ")"
|
-- 作者:lanbor -- 发布时间:2017/5/12 22:04:00 -- 再请教 谢谢专家帮助, 遍历所有节点的方法完全明白了,也正是我所求的! 针对:Tables("物料记录").Filter = "Category in (" & cs.trim(",") & ")" 要实现上语句,前提是这狐表里面的"物料记录"必先存在所有记录,才能实现在本地表中Filter Category 但当前我的"物料记录"只有一个结构,没有任何记录,我也只希望从SQL 库提取我需要的这一部分。 按照您提示,我想到了用下列语句 1. Data Tables("物料记录").SQLSelect("Category in (" & cs.trim(",") & ")") 测试了几次,一个记录也没有出来,应该是我不懂怎么正常用这个 IN 参数带“值”集的写法。 2. cmd.Com mandText = "Select * fr om {物料记录} where Category IN (" & cs.trim(",") & ")" " 请求指教上例1,2句的IN 子句正确写法。 谢谢你!
|
-- 作者:有点蓝 -- 发布时间:2017/5/12 22:08:00 -- Category列是整数还是字符型? Data Tables("物料记录").SQLSelect("Category in (\'" & cs.trim(",") & "\')") cmd.Com mandText = "Select * fr om {物料记录} where Category IN (\'" & cs.trim(",") & "\')"
|
-- 作者:lanbor -- 发布时间:2017/5/12 22:32:00 -- Category列是字符型? Category列是字符型 |
-- 作者:有点蓝 -- 发布时间:2017/5/12 22:36:00 -- 4楼代码测试有问题吗 |
-- 作者:lanbor -- 发布时间:2017/5/12 22:50:00 -- 实例. Dim cs As String = "\'" & e.node.name & "\'," For Each nd As winfo rm.treenode In e.node.AllNodes cs &= "\'" & nd.name & "\'," Next msgbox(cs) Dim su01 As Integer Dim cmd As new SQLCommand cmd.Com mandText = "Select * fr om {VW_BD_Product} where Category IN (\'" & cs.trim(",") & "\')" DTb03 = cmd.ExecuteReader() Tables(e.Fo rm.name & "_Table1").DataSource = DTb03 su01=DTb03.dataRows.count msgbox("记录数:" & str(su01)) Tables(e.Fo rm.name & "_table1").setcolvisiblewidth("GoodsNO|80|GoodsName|150|Description|200|CZ|80|UnitD|60|CategoryD|100|Color|80|UllagePercent|80|isFlagD|60|BarCode|100") Dim tb01 As Table = Tables(e.fo m.name & "_table1") \'当我点击节点为“1001" 的行后,以上代码,执行到:msgbox(cs) ,显示: \'1001\', 接下来就开始报告:‘1001‘ 附件有语法错误。 [此贴子已经被作者于2017/5/12 22:58:27编辑过]
|
-- 作者:有点蓝 -- 发布时间:2017/5/12 23:00:00 -- Dim cs As String = "\'" & e.node.name & "\'," For Each nd As winfo rm.treenode In e.node.AllNodes cs &= "\'" & nd.name & "\'," Next Dim su01 As Integer Dim cmd As new SQLCommand cmd.CommandText = "Select * from {VW_BD_Product} where Category IN (" & cs.trim(",") & ")" msgbox(cmd.CommandText ) ‘这里弹出什么内容 DTb03 = cmd.ExecuteReader() Tables(e.Fo rm.name & "_Table1").DataSource = DTb03 su01=DTb03.dataRows.count msgbox("记录数:" & str(su01)) Tables(e.Fo rm.name & "_table1").setcolvisiblewidth("GoodsNO|80|GoodsName|150|Description|200|CZ|80|UnitD|60|CategoryD|100|Color|80|UllagePercent|80|isFlagD|60|BarCode|100") Dim tb01 As Table = Tables(e.fo m.name & "_table1")
|
-- 作者:lanbor -- 发布时间:2017/5/12 23:10:00 -- msgbox(cmd.CommandText ) ‘这里弹出什么内容 msgbox(cmd.CommandText ) ‘这里弹出什么 内容就是CommandText后面的整个语句,其中IN 后面是:("1001\' \')
[此贴子已经被作者于2017/5/12 23:10:53编辑过]
|
-- 作者:lanbor -- 发布时间:2017/5/12 23:15:00 -- msgbox(cmd.CommandText ) ‘这里弹出什么 msgbox(cmd.CommandText ) ‘这里弹出什么 当我点节点1003 的行时。 报告如图所示。
|