Foxtable(狐表)用户栏目专家坐堂 → 将同一列的数据复制到另外一个表不同的列,如何串联。


  共有10506人关注过本帖树形打印复制链接

主题:将同一列的数据复制到另外一个表不同的列,如何串联。

帅哥哟,离线,有人找我吗?
huanghpp
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:10 积分:137 威望:0 精华:0 注册:2012/1/19 9:27:00
将同一列的数据复制到另外一个表不同的列,如何串联。  发帖心情 Post By:2012/1/30 11:04:00 [显示全部帖子]

将同一列的数据复制到另外一个表不同的列,如何串联。

代码如下:

Select Case e.DataCol.Name
    Case "C11"
    Dim dr As DataRow = DataTables("o").Find(" B11 = " & "'" & e.DataRow("C114") & "' And G = " & "'" & e.DataRow("C4") & "'" )
    If dr IsNot Nothing'如果找到,则设置各列内容
       dr("O")=e.DataRow("C11")
       dr("P")=e.DataRow("C12")
    End If
    Case "C11"
    Dim dr As DataRow = DataTables("o").Find(" B11 = " & "'" & e.DataRow("C114") & "' And W = " & "'" & e.DataRow("C4") & "'" )
    If dr IsNot Nothing'如果找到,则设置各列内容
       dr("A1")=e.DataRow("C11")
       dr("B1")=e.DataRow("C12")
    End If
    Case "C11"
    Dim dr As DataRow = DataTables("o").Find(" B11 = " & "'" & e.DataRow("C114") & "' And C1 = " & "'" & e.DataRow("C4") & "'" )
    If dr IsNot Nothing'如果找到,则设置各列内容
       dr("G1")=e.DataRow("C11")
       dr("H1")=e.DataRow("C12")
    End If
    Case "C11"
    Dim dr As DataRow = DataTables("o").Find(" B11 = " & "'" & e.DataRow("C114") & "' And I1 = " & "'" & e.DataRow("C4") & "'" )
    If dr IsNot Nothing'如果找到,则设置各列内容
       dr("M1")=e.DataRow("C11")
       dr("N1")=e.DataRow("C12")
    End If
End Select


 回到顶部
帅哥哟,离线,有人找我吗?
huanghpp
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:10 积分:137 威望:0 精华:0 注册:2012/1/19 9:27:00
  发帖心情 Post By:2012/1/30 13:52:00 [显示全部帖子]

就是要把各种条件组合起来,不知道怎么写代码,只好都写 Case "C11",

另外CZY写的代码提示有误,谢谢!!!


 回到顶部
帅哥哟,离线,有人找我吗?
huanghpp
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:10 积分:137 威望:0 精华:0 注册:2012/1/19 9:27:00
  发帖心情 Post By:2012/1/30 14:13:00 [显示全部帖子]

这样就可以了

Dim dt As DataTable = DataTables("o")
Dim s As String = "B11 = '" & e.DataRow("C114") & "'"
  Select Case e.DataCol.Name
  Case "C11"
    Dim dr As DataRow = dt.Find(s & " And G = '" & e.DataRow("C4") & "'" )
    If dr IsNot Nothing'如果找到,则设置各列内容
        dr("O")=e.DataRow("C11")
        dr("P")=e.DataRow("C12")
    End If
    Dim dr1 As DataRow = dt.Find(s & " And W = '" & e.DataRow("C4") & "'" )
    If dr1 IsNot Nothing'如果找到,则设置各列内容
        dr1("A1")=e.DataRow("C11")
        dr1("B1")=e.DataRow("C12")
    End If
    Dim dr2 As DataRow = dt.Find(s & " And C1 = '" & e.DataRow("C4") & "'" )
    If dr2 IsNot Nothing'如果找到,则设置各列内容
        dr2("G1")=e.DataRow("C11")
        dr2("H1")=e.DataRow("C12")
    End If
    Dim dr3 As DataRow = dt.Find(s & " And I1 = '"  & e.DataRow("C4") & "'" )
    If dr3 IsNot Nothing'如果找到,则设置各列内容
        dr3("M1")=e.DataRow("C11")
        dr3("N1")=e.DataRow("C12")
    End If
End Select

谢谢


 回到顶部
帅哥哟,离线,有人找我吗?
huanghpp
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:10 积分:137 威望:0 精华:0 注册:2012/1/19 9:27:00
  发帖心情 Post By:2012/1/30 14:16:00 [显示全部帖子]

这样就可以了

Dim dt As DataTable = DataTables("o")
Dim s As String = "B11 = '" & e.DataRow("C114") & "'"
  Select Case e.DataCol.Name
  Case "C11"
    Dim dr As DataRow = dt.Find(s & " And G = '" & e.DataRow("C4") & "'" )
    If dr IsNot Nothing'如果找到,则设置各列内容
        dr("O")=e.DataRow("C11")
        dr("P")=e.DataRow("C12")
    End If
    Dim dr1 As DataRow = dt.Find(s & " And W = '" & e.DataRow("C4") & "'" )
    If dr1 IsNot Nothing'如果找到,则设置各列内容
        dr1("A1")=e.DataRow("C11")
        dr1("B1")=e.DataRow("C12")
    End If
    Dim dr2 As DataRow = dt.Find(s & " And C1 = '" & e.DataRow("C4") & "'" )
    If dr2 IsNot Nothing'如果找到,则设置各列内容
        dr2("G1")=e.DataRow("C11")
        dr2("H1")=e.DataRow("C12")
    End If
    Dim dr3 As DataRow = dt.Find(s & " And I1 = '"  & e.DataRow("C4") & "'" )
    If dr3 IsNot Nothing'如果找到,则设置各列内容
        dr3("M1")=e.DataRow("C11")
        dr3("N1")=e.DataRow("C12")
    End If
End Select

谢谢


 回到顶部