Hi all,
I am making a simple box office type program, where users can book tickets, add events, admit the guests when presented with a ticket etc.
What I want to do is only allow certain functions to certain user types, so an administrator can add events and edit them as well as book the tickets and grant admission when a ticket is presented to them. And a standard user can only book tickets or grant admission.
So what I've done is created the bare bones of the database to hold event information, tickets sold and users. In the users table there is "Username", "Password" and "Admin?". "Admin?" is a 'Yes/No' data type in the database and I need to check if that box is checked or not so as to display the correct UI once the user has logged in. I can authenticate the user not a problem, I just don't know how to move forward to then check the "Admin?" field. My code for the login button is:
Just for info, 'iConnection' is declared outside of the click event and is just at the top in the main class for the login form. I know I need to put my code to check the user type the bold text above but I don't know where to start with that bit of the search.
I am making a simple box office type program, where users can book tickets, add events, admit the guests when presented with a ticket etc.
What I want to do is only allow certain functions to certain user types, so an administrator can add events and edit them as well as book the tickets and grant admission when a ticket is presented to them. And a standard user can only book tickets or grant admission.
So what I've done is created the bare bones of the database to hold event information, tickets sold and users. In the users table there is "Username", "Password" and "Admin?". "Admin?" is a 'Yes/No' data type in the database and I need to check if that box is checked or not so as to display the correct UI once the user has logged in. I can authenticate the user not a problem, I just don't know how to move forward to then check the "Admin?" field. My code for the login button is:
Code:
Dim BoxOfficeProvider As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source="
Dim BoxOfficeSource As String = "E:\Users\Wilko\Documents\Tickets.mdb"
Dim iUser As New OleDb.OleDbCommand("SELECT [ID] FROM [Users] WHERE [Username] = @username AND [Password] = @password", iConnection)
Dim usernameParam As New OleDb.OleDbParameter("@username", Me.Username.Text)
Dim passwordParam As New OleDb.OleDbParameter("@password", Me.Password.Text)
iUser.Parameters.Add(usernameParam)
iUser.Parameters.Add(passwordParam)
iConnection.ConnectionString = BoxOfficeProvider & BoxOfficeSource
iConnection.Open()
Dim reader As OleDb.OleDbDataReader = iUser.ExecuteReader()
If reader.HasRows Then
MsgBox("User authenticated")
Else
MsgBox("User not found")
End If
iConnection.Close()