vb2008关于从access取数的问题
我做了2个form,第一个form有一个lvzonglan(listview),从access取数列表,然后通过双击获得该行数据弹出到第二个frmMainuser(from)来展现,现在的问题是:比如说我第一次点击的ddid为1,frmMainuser能正常显示,但是关闭frmMainuser后,再次点击listview中其他项,结果显示的还是第一次的那个,请看代码:'双击事件
Private Sub lvZonglan_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvZonglan.DoubleClick
Dim ddid As String
For Each sItem As ListViewItem In lvZonglan.SelectedItems
ddid = sItem.Text
MessageBox.Show(ddid.ToString)
Next
With frmMainuser
.State = gModule.FormState.adStateEditMode
.MainuserID = ddid
.ShowDialog()
Call FillList()
End With
End Sub
'显示
Private Sub frmMainuser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cnMainuser As OleDbConnection
cnMainuser = New OleDbConnection
'MessageBox.Show("Mainuser窗体位置1:" & MainuserID)
Try
With cnMainuser
If .State = ConnectionState.Open Then .Close()
.ConnectionString = cnString
.Open()
End With
Catch ex As OleDbException
MsgBox(ex.ToString)
End Try
ElseIf State = gModule.FormState.adStateEditMode Then
Dim qryCustomers As String = "SELECT * FROM ddlistinfo WHERE ddid = '" & MainuserID & "'"
daMainuser.SelectCommand = New OleDbCommand(qryCustomers, cnMainuser)
Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(daMainuser)
daMainuser.Fill(dsMainuser, "ddid")
Dim dt As DataTable = dsMainuser.Tables("ddid")
Try
lblDdid.Text = dt.Rows(0)("Ddid")
lbltype.Text = dt.Rows(0)("Type")
lblCycle.Text = IIf(IsDBNull(dt.Rows(0)("Cycle")), "", dt.Rows(0)("Cycle")) & " 天"
lblJhrq.Text = IIf(IsDBNull(dt.Rows(0)("Jhrq")), "", dt.Rows(0)("Jhrq"))
lblGwsj.Text = IIf(IsDBNull(dt.Rows(0)("Gwsj")), "", dt.Rows(0)("Gwsj")) & " 小时"
lblState.Text = IIf(IsDBNull(dt.Rows(0)("State")), "", dt.Rows(0)("State"))
lblfixer.Text = IIf(IsDBNull(dt.Rows(0)("Fixer")), "", dt.Rows(0)("Fixer"))
lblYnqa.Text = IIf(IsDBNull(dt.Rows(0)("Ynqa")), "", dt.Rows(0)("Ynqa"))
lblintime.Text = IIf(IsDBNull(dt.Rows(0)("intime")), "", dt.Rows(0)("intime"))
If lblState.Text = "QA完成" Or lblYnqa.Text = "否" Then
btnUdone.Enabled = True
Else
btnUdone.Enabled = False
End If
Catch ex As OleDbException
MsgBox(ex.ToString)
Finally
cnMainuser.Close()
End Try
End If
End Sub
请问 这是为什么呢?