1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Dim strCon$ = CStr("provider=microsoft.jet.oledb.4.0;" & "data source= " & Chemin_Acces_BD & "\" & "BDAccess.mdb;")
Cn = New OleDb.OleDbConnection(strCon)
Cn.ConnectionString = strCon
Cn.Open()
CmdR = Cn.CreateCommand() 'Creation de commande
CmdR.CommandText = "select Nom_Admin, Passwd_Admin from admin WHERE Nom_admin = '" & Me.Txt_Nom_Admin.Text.ToString & "'" ' Creation de la requete SQL"
Try
' Extraire l'enregistrement courant
DtSet = New DataSet
DtAdapteur = New OleDb.OleDbDataAdapter
DtAdapteur.SelectCommand = CmdR
DtSet.Tables("admin").Rows(0).BeginEdit() ' ca plante ici!!!!
DtRow = DtSet.Tables("admin").Rows(0)
'Modifier les valeurs des champs en récupérant le contenu des TextBox
DtRow("nom_admin") = Me.Txt_new_UserName_Admin.Text
DtRow("passwd_admin") = Me.Txt_Confirmation_New_PassAdmin.Text
'Pour modifier les valeurs changées dans le DataAdapter
cmdBuilder = New OleDb.OleDbCommandBuilder(DtAdapteur)
'Mise à jour
DtAdapteur.Update(DtSet, "Admin")
Cn = Nothing
CmdR = Nothing
DtAdapteur = Nothing
'Objet déconnectée
DtSet = Nothing
DtTable = Nothing
DtRow = Nothing
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information)
Cn = Nothing
CmdR = Nothing
DtAdapteur = Nothing
'Objet déconnectée
DtSet = Nothing
DtTable = Nothing
DtRow = Nothing
End Try
Cn = Nothing
CmdR = Nothing
DtAdapteur = Nothing
'Objet déconnectée
DtSet = Nothing
DtTable = Nothing
DtRow = Nothing |
Partager