Public Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim sql = "SELECT UserID, fullname, userLevel FROM tblUser WHERE LoginName='" & txtUserName.Text & "' AND LoginPassword='" & txtPassword.Text & "'"
Dim conn As OleDbConnection = carDba.getCn
Dim cmd As OleDbCommand
Dim dsUser As New DataSet
cmd = New OleDbCommand(sql, conn)
conn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Try
If dr.Read = False Then
MessageBox.Show("Authentication failed, please ensure that the username and password you entered are correct...", MessageBoxButtons.RetryCancel)
conn.Close()
Exit Sub
Else
'puts userId and full name into global variables
dbaCAR.UserId = dr.GetValue(0)
dbaCAR.strFullName = dr.GetString(1)
dbaCAR.intUserLevel = dr.GetValue(2)
Dim main As New mdiCAR
With main
.WindowState = FormWindowState.Maximized
.ControlBox = True
.Show()
End With
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
Dim sql = "SELECT UserID, fullname, userLevel FROM tblUser WHERE LoginName='" & txtUserName.Text & "' AND LoginPassword='" & txtPassword.Text & "'"
Dim conn As OleDbConnection = carDba.getCn
Dim cmd As OleDbCommand
Dim dsUser As New DataSet
cmd = New OleDbCommand(sql, conn)
conn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Try
If dr.Read = False Then
MessageBox.Show("Authentication failed, please ensure that the username and password you entered are correct...", MessageBoxButtons.RetryCancel)
conn.Close()
Exit Sub
Else
'puts userId and full name into global variables
dbaCAR.UserId = dr.GetValue(0)
dbaCAR.strFullName = dr.GetString(1)
dbaCAR.intUserLevel = dr.GetValue(2)
Dim main As New mdiCAR
With main
.WindowState = FormWindowState.Maximized
.ControlBox = True
.Show()
End With
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub