以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 将同一列的数据复制到另外一个表不同的列,如何串联。 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=16007)
|
-- 作者:huanghpp
-- 发布时间: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
|
-- 作者:狐狸爸爸
-- 发布时间:2012/1/30 11:52:00
--
没有看懂你的代码,怎么这么多:Case "C11"
只有一个会生效的。
|
-- 作者:czy
-- 发布时间:2012/1/30 12:05:00
--
这样看看行不行?
Select Case e.DataCol.Name Dim dt As DataTable = DataTables("o") Dim s As String = "B11 = \'" & e.DataRow("C114") & "\'" Case "C11" Dim dr As DataRow = t.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 = t.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 = t.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 = t.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
-- 发布时间:2012/1/30 13:52:00
--
就是要把各种条件组合起来,不知道怎么写代码,只好都写 Case "C11",
另外CZY写的代码提示有误,谢谢!!!
|
-- 作者:huanghpp
-- 发布时间: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
-- 发布时间: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
谢谢
|