以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 递归函数问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=79386) |
||||
-- 作者:fubblyc -- 发布时间:2015/12/30 13:24:00 -- 递归函数问题 |
||||
-- 作者:大红袍 -- 发布时间:2015/12/30 14:09:00 -- 参考
http://www.foxtable.com/help/topics/2416.htm
|
||||
-- 作者:大红袍 -- 发布时间:2015/12/30 14:41:00 -- children函数
Dim pdr As DataRow = args(0)
children2
Dim cdr As DataRow = args(0)
调用 Dim dt As DataTable = DataTables("表A") For Each dr As DataRow In dt.Select("第一列 is null") Functions.Execute("AddChildren",dr, DataTables("表B")) Next Tables("表B").Sort = "第一列,第三列"
|
||||
-- 作者:fubblyc -- 发布时间:2016/1/13 10:08:00 -- 谢谢 大红袍 老师。 如果我想在直接在我的sql2005数据库上写,类似于:
|
||||
-- 作者:fubblyc -- 发布时间:2016/1/13 10:08:00 -- 举例: 有这样一个表: ![]() ![]() 要在数据库上写生成这样的表: ![]() ![]() 也就是得到父级 三级 万分感谢!! |
||||
-- 作者:fubblyc -- 发布时间:2016/1/13 10:10:00 -- 百度查了,好像有这样的函数:
![]() ![]() |
||||
-- 作者:大红袍 -- 发布时间:2016/1/13 10:12:00 -- 必须用代码处理。你看懂递归自己学习sql处理。
sql也可以用递归,就是麻烦。 |
||||
-- 作者:fubblyc -- 发布时间:2016/1/13 10:38:00 -- 好吧,那我先用FT先实现。 哎,看半天不知道怎么写,大红袍老师,那要不我把示例项目发上来,你帮我看下。。。。
就一个表: 实现成这样:
|
||||
-- 作者:Hyphen -- 发布时间:2016/1/13 11:38:00 -- AddChildren函数 Dim pdr As DataRow = args(0) Dim dt As DataTable = args(1) Dim cardnum As String = args(2) Dim idx As Integer = args(3) Dim dr As DataRow = dt.Find("卡号 = \'" & cardnum & "\'") If dr IsNot Nothing Then Select Case idx Case 1 pdr("一级推荐人卡号") = pdr("推荐人卡号") Functions.Execute("AddChildren",pdr ,dt, pdr("推荐人卡号"),idx+1) Case 2 pdr("二级推荐人卡号") = dr("推荐人卡号") Functions.Execute("AddChildren",pdr ,dt, dr("推荐人卡号"),idx+1) Case 3 pdr("三级推荐人卡号") = dr("推荐人卡号") End Select End If 调用 Dim dr As DataRow = CurrentTable.Current.DataRow Functions.Execute("AddChildren",dr,CurrentTable.DataTable,dr("推荐人卡号"),1) |
||||
-- 作者:fubblyc -- 发布时间:2016/2/29 21:21:00 -- 谢谢 Hyphen 老师,我照着做了,不知道怎么没有有反应。。。不知道是不是哪错了。。。 |