title: username and password verification vb.net
body: <p>My program below checks if the userName and the password is in the database( written in visual basic and uses Access database). The program works however, when I type in the userName or password in a different case it still works. For example, if my database has the userName as "john" and the password as "johnspassword", my program accepts the username as "JOHN" and password as "JOHNSPASSWORD".</p>
  
  <p>how do i resolve this problem?</p>
  
  <pre><code>Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\Users\jacob\Desktop\MS Office\project.mdb")
      Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM tblUsers WHERE UserID = '" &amp; txtUserName_Field.Text &amp; "' AND userPassword = '" &amp; txtUserPassword_Field.Text &amp; "' ", con)
      con.Open()
      Dim sdr As OleDbDataReader = cmd.ExecuteReader()
      'If the record can be queried, it means passing verification, then open another form.
      Dim empty =
      Me.Controls.OfType(Of TextBox)().Where(Function(txt) txt.Text.Length = 0)
      If empty.Any Then
          MessageBox.Show(String.Format("Please fill in all the fields required"))
      Else
          If (sdr.Read() = True) Then
              MessageBox.Show("The is valid!")
              Form4.Show()
              Me.Hide()
          Else
              MessageBox.Show("Invalid name or password!")
          End If
      End If
      con.Close()
  End Sub
  </code></pre>