I have a class where I will get the value of username and password of my login form and pass it to admin form.
Public Property getUsername() As String
Get
Return Login.username.Text
End Get
Set(value As String)
uname = value
End Set
End Property
Public Property getPassword() As String
Get
Return Login.password.Text
End Get
Set(value As String)
pword = value
End Set
End Property
A function getName()
Public Function getName()
con.Open()
Dim sd As New SqlDataAdapter("select * from AdminAcc where Username = '" & getUsername() & "'", con)
Dim dt As New DataTable
sd.Fill(dt)
con.Close()
getName = dt.Rows(0)(1).ToString()
End Function
I want to display the name of that user in my form so I tried this one:
Private Sub AdminM_Load(sender As Object, e As EventArgs) Handles MyBase.Load
admingreeting.Text = "Hi, " + queryclass.getName()
End Sub
It is actually working, but when I try to sign out the application stops and a break mode window appears.
Private Sub btnsignout_Click(sender As Object, e As EventArgs) Handles btnsignout.Click
If MsgBox("Are you sure you want to sign out?", vbQuestion + vbYesNo) = vbYes Then
Login.Show()
Me.Close()
End If
End Sub
I tried using the me.hide() and it worked, but when I tried to login another acc, the value in the previous getName() did not change.