I am creating login pages using asp.net with code behind in vb.net, I am newbie:D. My problem is how to pass the login name to another page. First, whenever I login it will identify if it is an administrator shown in a msgbox. The user requirement is that the employee name is displayed as login not the username. Here is my code. Thanks in advance.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmd1 As New SqlCommand
Dim rdr As SqlDataReader
cmd1.Connection = cn
cmd1.Connection.Open()
cmd1.CommandText = "SELECT * from UserTable WHERE Username ='" & txt_username.Text & "'"
rdr = cmd1.ExecuteReader
If rdr.HasRows = True Then
rdr.Read()
If txt_username.Text = rdr.Item(0) And txt_password.Text = rdr.Item(3) Then
CurPos = rdr.Item("Type")
CurUser = rdr.Item("Username")
CurName = rdr.Item("EmployeeName")
If rdr.Item(4) = "ADMINISTRATOR" Then
MsgBox("WELCOME! " & rdr.Item(4), MsgBoxStyle.Information)
Main.lbl_name.Text = CurName.ToUpper 'it's not working
POS.lbl_cashier.Text = CurName.ToUpper ' it's not working
Response.Redirect("ACESCHOOLSUPPLIES.aspx")
cmd1.Connection.Close()
'Me.Dispose()
Else
MsgBox("WELCOME! " & rdr.Item(4), MsgBoxStyle.Information)
cmd1.Connection.Close()
Response.Redirect("POS.aspx")
End If