Page 1 of 1

Access database

Posted: Mon Aug 29, 2016 10:12 pm
by Mark
Hello,

I use this code below it logs me in fine all working i have a filed called roll say i have the roll as Admin and i want to display a menu strip how do i go about this but if there normal account type then the menu strip wont show this is the code i have at the moment?
Code: Select all
 Private Sub login()
        Try
            sqL = "SELECT * FROM users WHERE Username = '" & txtUsername.Text & "' AND Password = '" & txtPassword.Text & "'"
            ConnDB()
            cmd = New OleDbCommand(sqL, conn)
            dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
            If dr.Read = True Then
                txtUsername.Text = ""
                txtPassword.Text = ""
                Me.Close()
            Else
                MsgBox("Incorrect username or Password!", MsgBoxStyle.Critical, "Login")
                txtPassword.Focus()
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            cmd.Dispose()
            conn.Close()
        End Try
    End Sub
Thanks

Mark

Re: Access database

Posted: Tue Aug 30, 2016 7:50 pm
by CodenStuff
Sending this from mobile so can't go into depths at the moment but I figure it would be quite simple.

Here are the steps:
- user logs-in
- on successful log-in, run query and get users roll
- store users roll in global variable, boolean perhaps
- now just run your code to check if variable is true or false
- if true, user is admin, show menustrip..etc