| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 547 人关注过本帖
标题:vb2008关于从access取数的问题
只看楼主 加入收藏
pirate913
Rank: 2
等 级:论坛游民
帖 子:2
专家分:20
注 册:2011-5-18
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
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

请问 这是为什么呢?
搜索更多相关主题的帖子: access Object 
2011-05-18 10:56
wlzh1004
Rank: 2
等 级:论坛游民
帖 子:2
专家分:20
注 册:2011-5-18
收藏
得分:20 
我也正想了解这个问题,等高手来解答
2011-05-18 19:39
快速回复:vb2008关于从access取数的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.081666 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved