以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  二表间光标对应?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=54514)

--  作者:jk362223
--  发布时间:2014/7/29 22:47:00
--  二表间光标对应?
二表间光标对应,在主表CurrentChanged设置
If e.Table.Current Is Nothing Then \'如果Current为Nothing
    Return \'则返回
End If
Dim wz1 As Integer
Dim dr1 As DataRow
dr1 = DataTables("资料扫描").Find("[身份证号] = \'" & e.Table.Current("身份证号") & "\'")
If dr1 IsNot Nothing Then
    wz1 = Tables("资料扫描").FindRow(dr1)
    If wz1 >= 0 Then
        Tables("资料扫描").Position = wz1
    End If
End If
现在的问题是"资料扫描"没加载,在后台,无法让光标相互对应,代码要怎么写?用sqlfind不行啊


--  作者:y2287958
--  发布时间:2014/7/29 22:49:00
--  
SQLCommand
--  作者:有点甜
--  发布时间:2014/7/29 22:51:00
--  
If e.Table.Current Is Nothing Then \'如果Current为Nothing
    Return \'则返回
End If
Dim wz1 As Integer
Dim dr1 As DataRow
Dim filter As String = "[身份证号] = \'" & e.Table.Current("身份证号") & "\'"
dr1 = DataTables("资料扫描").Find(filter)
If dr1 Is Nothing Then
    DataTables("资料扫描").AppendLoad(filter)
End If
wz1 = Tables("资料扫描").FindRow(filter)
If wz1 >= 0 Then
    Tables("资料扫描").Position = wz1
End If

--  作者:jk362223
--  发布时间:2014/7/29 22:53:00
--  
还有一个问题是,若表A,表B在后台,下面设置不能完成引用,
Dim nmc() As String = {"第一列","第二列"} \'A表数据来源列
Dim nmd() As String = {"第一列","第二列"} \'B表数据接收列
Dim dra As Row = Tables("表A").Current
Dim drc As Row = Tables("表C").AddNew
For i As Integer = 0 To nmc.Length - 1
    drc(nmd(i)) = dra(nmc(i))
Next
Dim nma() As String = {"第一列","第二列"} \'A表数据来源列
Dim nmb() As String = {"第三列","第四列"} \'B表数据接收列
Dim drb As Row = Tables("表B").Current
Dim dr As Row = Tables("表C").Current
For i As Integer = 0 To nma.Length - 1
    dr(nmb(i)) = drb(nma(i))
Next
这是多表多列引用,若表A,表B数据在后台,如何引用?

--  作者:有点甜
--  发布时间:2014/7/29 22:54:00
--  

 表a,表b,在后台,就没有所谓的current一说啊。


--  作者:有点甜
--  发布时间:2014/7/29 22:55:00
--  
 如果要查找行,可以用sqlFind,或者用sqlcommand
--  作者:jk362223
--  发布时间:2014/7/30 0:17:00
--  
那具体的代码如何写啊?
--  作者:jk362223
--  发布时间:2014/7/30 8:07:00
--  
是不是这样?
Dim nmc() As String = {"第一列","第二列"} \'A表数据来源列
Dim nmd() As String = {"第一列","第二列"} \'B表数据接收列
Dim dra As Row = Tables("表A").Current
Dim drc As Row = Tables("表C").AddNew
For i As Integer = 0 To nmc.Length - 1
    drc(nmd(i)) = dra(nmc(i))
Next

Dim cmd As New SQLCommand
Dim dt As DataTable
Dim Cols1() As String = {"来源列一","来源列二","来源列三"}
Dim Cols2() As String = {"接收列一","接收列二","接收列三"}
cmd.CommandText = "SELECT * From {表B} Where 条件语句"
dt = cmd.ExecuteReader()
For Each dr1 As DataRow In dt.DataRows
    Dim dr2 As DataRow = DataTables("表C").Current()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next

--  作者:Bin
--  发布时间:2014/7/30 8:47:00
--  
你的需求是什么,按照你8楼的代码,这样会遍历你查找出来的行, 一直覆盖直到最后一条


Dim nmc() As String = {"第一列","第二列"} \'A表数据来源列
Dim nmd() As String = {"第一列","第二列"} \'B表数据接收列
Dim dra As Row = Tables("表A").Current
Dim drc As Row = Tables("表C").AddNew
For i As Integer = 0 To nmc.Length - 1
    drc(nmd(i)) = dra(nmc(i))
Next
Dim nma() As String = {"第一列","第二列"} \'A表数据来源列
Dim nmb() As String = {"第三列","第四列"} \'B表数据接收列
Dim drb As Row = dataTables("表B").SQLFIND("条件语句")
Dim dr As Row = Tables("表C").Current
For i As Integer = 0 To nma.Length - 1
    dr(nmb(i)) = drb(nma(i))
Next

[此贴子已经被作者于2014-7-30 8:47:16编辑过]

--  作者:jk362223
--  发布时间:2014/7/30 11:38:00
--  
Dim drb As Row = dataTables("表B").SQLFIND("条件语句")
若是没有("条件语句"),是不是可以这样写?
Dim drb As Row = dataTables("表B").SQLFIND()