title: Showing a message box when username and password is incorrect
body: <p>I have a login form for my program and it works fine but when i input an username and password that is not in my database, the textbox for the username and password just clears the text and does not show the messagebox that says "incorrect username/password"</p>
  
  <p>Here is my code:</p>
  
  <pre><code> Dim con As OleDbConnection = New OleDbConnection( _
                 "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= UserPass.mdb;")
      con.Open()
      Dim str As String
      str = "SELECT * FROM UserPass WHERE Username='" &amp; txtUsername.Text &amp; "' AND Password='" &amp; txtPassword.Text &amp; "'"
      Dim cmd As OleDbCommand = New OleDbCommand(str, con)
      cmd.Parameters.AddWithValue("user", txtUsername.Text)
      cmd.Parameters.AddWithValue("pass", txtPassword.Text)
      Dim sdr As OleDbDataReader = cmd.ExecuteReader()
      ' It will be case sensitive if you compare usernames here.   
      If sdr.HasRows Then
          If sdr.Read Then
              If txtPassword.Text &lt;&gt; sdr("Password").ToString Or txtUsername.Text &lt;&gt; sdr("Username").ToString Then
                  MessageBox.Show(" Incorrect Username/Password. Login Denied ", " Error! ", MessageBoxButtons.OK, MessageBoxIcon.Error)
              Else
                  MessageBox.Show(" You are now Logged In! ", " Welcome! ", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
                  frmOne.Show()
                  Me.Hide()
              End If
          End If
      End If
  </code></pre>
  
  <p>How can i make my program show a messagebox when i input a username and password that is not in my database?</p>