以下代码能在窗口的两个表中加载表与明细表,但不能达到选定行后,筛选出对应的关联表:窗口1的AfterLoaD代码为
Dim cmd As New SQLCommand
cmd.C
'生成表
Dim i As Integer
cmd.CommandText = "execute CX"
Dim dst1 As Table = Tables("窗口1_Table1")
dst1.DataSource = cmd.ExecuteReader()
For i=1 To dst1.count
Dim dr As Row = dst1.Rows(i-1)
dr("序号") = "" & i
Next
'生成明细表
Dim dst2 As Table = Tables("窗口1_Table2")
If dst1.count>0 Then
Dim dr1 As Row = dst1.Current '获得选定行
Dim str As String = dr1("项目代码")
cmd.CommandText = "execute Cxa '" & str & "'"
End If
dst2.DataSource = cmd.ExecuteReader()
For i=1 To dst2.count
Dim dr As Row = dst2.Rows(i-1)
dr("序号") = "" & i
Next
以上的步骤可以生成表与明细表
窗口1_Table1的CurrentChanged代码为:
'筛选出明细
Dim cmd As New SQLCommand
cmd.C
Dim dst1 As Table = Tables("窗口1_Table1")
Dim dst2 As Table = Tables("窗口1_Table2")
If dst1.count>0 Then
Dim dr1 As Row = dst1.Current '获得选定行
Dim str As String = dr1("项目代码")
Else
cmd.CommandText = "execute CXA "
End If
dst2.DataSource = cmd.ExecuteReader()
Dim i As Integer
For i=1 To dst2.count
Dim dr As Row = dst2.Rows(i-1)
dr("序号") = "" & i
Next
提示的错误就是选定表中的记录,不能筛选出明细表,并提示序号不在Table2表中