Imports System.Data.OleDb
Imports System.Data
Public Class FChange
    Dim Pass1Connection As OleDbConnection
    Dim Pass1Command As OleDbCommand
    Dim Pass1Table As New DataTable
    Dim Pass1Adapter As OleDbDataAdapter
    Dim Pass1Manager As CurrencyManager

    Dim NumTries As String ' This variable contains Number that the user will enter password
    Private Sub FChange_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Pass1Connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Pass1.mdb")
        Pass1Connection.Open()
        Pass1Command = New OleDbCommand("SELECT * FROM Pass1 ORDER BY Pass", Pass1Connection)
        Pass1Adapter = New OleDbDataAdapter()
        Pass1Adapter.SelectCommand = Pass1Command
        Pass1Table = New DataTable()
        Pass1Adapter.Fill(Pass1Table)
        Password.DataBindings.Add("Text", Pass1Table, "Pass")
        UserName.DataBindings.Add("Text", Pass1Table, "UserName")
        Password.Text = Nothing
        UserName.Text = Nothing

        Pass1Manager = DirectCast(Me.BindingContext(Pass1Table), CurrencyManager)


    End Sub
    Private Sub BtnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEnter.Click

        Dim SavedItem As String = Password.Text
        Dim SavedRow As Integer
        Pass1Manager.EndCurrentEdit()

        Pass1Table.DefaultView.Sort = "Pass"
        SavedRow = Pass1Table.DefaultView.Find(SavedItem)
        Pass1Manager.Position = SavedRow
        Try
            'save the update  table
            Dim TarifeAdapterCommands As New OleDbCommandBuilder(Pass1Adapter)
            Pass1Adapter.Update(Pass1Table)
            MsgBox("Le Mot de Passe a été changé", MsgBoxStyle.Information)
            Me.Hide()

        Catch ex As Exception
            MessageBox.Show(ex.Message, "Erreur de basse de données Sauvegarde", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        'close the connection
        'dispose of the objects
        Pass1Command.Dispose()
        Pass1Adapter.Dispose()
        Pass1Table.Dispose()
    End Sub

    Private Sub BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEdit.Click
        End

    End Sub
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If RadioButton1.Checked = True Then
            Password.PasswordChar = ""

        End If
    End Sub
End Class