title: Change password in access database through visual basic form
body: <p>I currently have a form where you can enter a <code>username</code> and <code>password</code> and it creates a record of it in access. From there, whenever it asks for a <code>username</code> and <code>password</code>, you enter yours and it checks to see if it is correct. I have all of this working correctly but now I have a separate form where you can change you <code>password</code> but I don't know how I would do that. Here is what I have so far:</p>
  
  <pre><code>Dim con As OleDbConnection = New OleDbConnection()
  Dim cmd As OleDbCommand
  Dim sql = "SELECT UN, PW FROM Users WHERE UN='" &amp; cmbUser.Text &amp; "' AND PW='" &amp; txtOldPass.Text &amp; "'"
  cmd = New OleDbCommand(sql, con)
  con.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../Database.mdb")
  con.Open()
  Dim dr As OleDbDataReader = cmd.ExecuteReader
  
  Try
     If dr.Read = False Then
        MsgBox("Password is incorrect!")
        txtOldPass.Text = ""
        txtNewPass.Text = ""
        txtNewPassConf.Text = ""
     ElseIf txtNewPass.Text &lt;&gt; txtNewPassConf.Text Then
        MsgBox("Passwords do not match!")
        txtOldPass.Text = ""
        txtNewPass.Text = ""
        txtNewPassConf.Text = ""
     Else
        'This is where the change password code goes
        MsgBox("You password has been changed!")
        cmbUser.SelectedIndex = -1
        txtOldPass.Text = ""
        txtNewPass.Text = ""
        txtNewPassConf.Text = ""
     End If
  Catch ex As Exception
     MsgBox(ex.Message)
  End Try
  con.Close()
  </code></pre>
  
  <p>As you can see, everything seems to be working just fine. Just need code to change the value of the PW cell. I think I could use the <code>sql</code> string but I am not sure exactly how. Thanks in advance!</p>