Update dataset depuis dataadapter
Bonjour à tous,
J'ai créer un formulaire windows qui affiche les données d'une table Access.
Voici le code qui m'affiche les données dans mes différentes textbox (rattachées à ma base Access)
Code:
1 2 3
| Private Sub Fiche_Load(sender As Object, e As EventArgs) Handles Me.Load
Me.T_JeuxTableAdapter.Fill(LudothequeDataSet.T_Jeux)
End Sub |
Je voudrai actualiser les données de ma base access si un utilisateur fait des modifications dans les différentes textbox.
Voici le code de mon bouton de Mise a jour
Code:
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
| Private Sub Button_MAJ_Click(sender As Object, e As EventArgs) Handles Button_MAJ.Click
Dim deletedChildRecords As LudothequeDataSet.T_JeuxDataTable =
CType(Me.LudothequeDataSet.T_Jeux.GetChanges(Data.DataRowState.Deleted), LudothequeDataSet.T_JeuxDataTable)
Dim newChildRecords As LudothequeDataSet.T_JeuxDataTable =
CType(Me.LudothequeDataSet.T_Jeux.GetChanges(Data.DataRowState.Added), LudothequeDataSet.T_JeuxDataTable)
Dim modifiedChildRecords As LudothequeDataSet.T_JeuxDataTable =
CType(Me.LudothequeDataSet.T_Jeux.GetChanges(Data.DataRowState.Modified), LudothequeDataSet.T_JeuxDataTable)
Try
If deletedChildRecords IsNot Nothing Then
T_JeuxTableAdapter.Update(deletedChildRecords)
End If
T_JeuxTableAdapter.Update(Me.LudothequeDataSet.T_Jeux)
If newChildRecords IsNot Nothing Then
T_JeuxTableAdapter.Update(newChildRecords)
End If
If modifiedChildRecords IsNot Nothing Then
T_JeuxTableAdapter.Update(modifiedChildRecords)
End If
Me.LudothequeDataSet.AcceptChanges()
' MessageBox.Show(LudothequeDataSet.Tables("T_Jeux").Rows(0).Item("Age").ToString)
Catch ex As Exception
MessageBox.Show("Erreur")
Finally
If deletedChildRecords IsNot Nothing Then
deletedChildRecords.Dispose()
End If
If newChildRecords IsNot Nothing Then
newChildRecords.Dispose()
End If
If modifiedChildRecords IsNot Nothing Then
modifiedChildRecords.Dispose()
End If
End Try
End Sub |
Le souci c'est qu'à chaque ouverture de mon formulaire mes données sont perdue (la valeur de la message box en commentaire elle est bien modifiée)
Une idée du problème?
Merci d'avance de m'apporter vos lumières...