窗体刷新参数传递

时间:2014-12-11 10:57:03

标签: vb.net

我目前正在使用Vb.net

进行visual studio窗体测试

我想刷新用户登录名并将参数传递给其他表单。但每次我成功登录第一个用户,当我重新登录到另一个用户。它与第一个用户保持相同的数据

Private authUser As custMain = New custMain()
Dim id As String
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
    If sql.HasConnection Then

        If isAuthenticated() = True Then

            sql.RunQuery("select UID from userAccount where username='" & txtUsername.Text & "' and password = '" & txtPassword.Text & "' and userType='cust'")
            For Each i As Object In sql.SQLDS.Tables(0).Rows
                id = i.item("UID")
            Next
            authUser.AuthName = id
            authUser.Invalidate()
            authUser.Refresh()
            authUser.Show()
            Me.Hide()
        End If
    End If
End Sub

1 个答案:

答案 0 :(得分:1)

使用此代码。

Private authUser As custMain 
Dim id As String
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
    If sql.HasConnection Then

        If isAuthenticated() = True Then

            sql.RunQuery("select UID from userAccount where username='" & txtUsername.Text & "' and password = '" & txtPassword.Text & "' and userType='cust'")
            For Each i As Object In sql.SQLDS.Tables(0).Rows
                id = i.item("UID")
            Next
            authUser = New custMain()
            authUser.AuthName = id
            authUser.Show()
            Me.Hide()
        End If
    End If
End Sub