title: How do I check if a user has a certain role in their profile?
body: <p><strong>Good-day,</strong></p>
  
  <p>I need some help.  I'm trying to query my MySQL database to see if the currently logged on user to my application has certain rights/role.  If the queried value does exist, then I want to enable a certain menu item.</p>
  
  <p>I checked out most of the similar questions as I was typing my question, but they mostly deal with ASP and JSP so that confuses me even further (as I haven't studied those yet).  I'm still learning VB.Net and MySQL.</p>
  
  <p>Your help would be greatly appreciated.</p>
  
  <p><strong>Here's my code - what am I not doing right?:</strong></p>
  
  <pre><code>Public Sub checkAccessLevel()
      Dim dbConn As New MySqlConnection(String.Format("Server={0};Port={1};Uid={2};Password={3};Database=parts", FormLogin.ComboBoxServerIP.SelectedItem, My.Settings.DB_Port, My.Settings.DB_UserID, My.Settings.DB_Password))
      Dim dbQuery As String = "SELECT Level FROM users WHERE username = '" &amp; FormLogin.TextBoxUsername.Text &amp; "'"
      Dim dbAdapter As New MySqlDataAdapter(dbQuery, dbConn)
      Dim dbData As MySqlDataReader
  
      Try
          dbConn.Open()
          dbData = dbAdapter.SelectCommand.ExecuteReader
          dbData.Read()
          While dbData.Read
              Select Case UCase(dbData(0).ToString)
                  Case Is = "Admin"
                      TSMenuItemOptions.Enabled = True
                  Case Is = "Manager"
                      TSMenuItemOptions.Enabled = True
                  Case Is = "User"
                      TSMenuItemOptions.Enabled = False
              End Select
          End While
          dbData.Close()
  
      Catch ex As Exception
          MessageBox.Show("A DATABASE ERROR HAS OCCURED" &amp; vbCrLf &amp; vbCrLf &amp; ex.Message &amp; vbCrLf &amp; _
                              vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.")
      Finally
          dbAdapter.Dispose()
          dbConn.Close()
      End Try
  
  End Sub
  </code></pre>