以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=103099)

--  作者:minxizai
--  发布时间:2017/6/30 14:55:00
--  [求助]
希望结算账户变更后,所有表中含结算账户的行一起变更,

问题1:假设数据库有很多不同项目的表,   
        For Each dt As DataTable In DataTables
        If dt.Name = "结算账户" Then
       这样查找的表是数据库中的表,还是项目中表?
问题2:下面的代码为什么没用?

If e.DataCol.Name = "结算账户" Then
    For Each dt As DataTable In DataTables
        If dt.Name = "结算账户" Then
            Continue For
            For Each dr As DataCol In dt.DataCols
                If dr.Name = "结算账户" Then
                    Dim ds As List(of DataRow)
                    ds = dt.Select("结算账户 = \'" & e.OldValue & "\'")
                    If ds IsNot Nothing Then
                        For Each d As DataRow In ds
                            d("结算账户") = e.NewValue
                        Next
                    End If
                End If
            Next
        End If
    Next
End If

--  作者:有点甜
--  发布时间:2017/6/30 16:06:00
--  

1、参考

 

for each dt as datatable in datatables
    output.show(dt.ConnectionName)
Next

 

2、

 

If e.DataCol.Name = "结算账户" Then
    For Each dt As DataTable In DataTables
        If dt.DataCols.Contains("结算账户") Then
            dt.ReplaceFor("结算账户", e.newvalue, "结算账户 = \'" & e.oldvalue & "\'")
        End If
    Next
End If


--  作者:minxizai
--  发布时间:2017/6/30 16:24:00
--  还是不行
还是不行啊
If e.DataCol.Name = "结算账户" Then
    For Each dt As DataTable In DataTables
        If dt.Name = "结算账户" Then
            Continue For
            If dt.DataCols.Contains("结算账户") Then
                dt.ReplaceFor("结算账户", e.newvalue, "结算账户 = \'" & e.oldvalue & "\'")
            End If
        End If
    Next
End If


--  作者:blsu33
--  发布时间:2017/6/30 16:38:00
--  
Continue For
如果是成立,则继续下一次循环,本次不执行Continue For的代码了,感觉需要去掉,3楼的Continue For去掉试试
你的代码试试下面的行不行
If e.DataCol.Name = "结算账户" Then
    For Each dt As DataTable In DataTables
        If dt.Name = "结算账户" Then
            ‘Continue For ’是否多余啊
            For Each dr As DataCol In dt.DataCols
                If dr.Name = "结算账户" Then
                    Dim ds As List(of DataRow)
                    ds = dt.Select("结算账户 = \'" & dr("结算账户") & "\'")
                    If ds IsNot Nothing Then
                        For Each d As DataRow In ds
                            d("结算账户") = e.NewValue
                        Next
                    End If
                End If
            Next
        End If
    Next
End If




--  作者:minxizai
--  发布时间:2017/6/30 16:43:00
--  
去掉continue 可以了,谢谢