Bonjour à tous,

Lors de mon form_load j'affiche mon datagridView :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
    Private Sub liste_famille_forage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        DboutillageDataSet.Clear()
 
       Me.Table_forage_familleTableAdapter.Fill(Me.DboutillageDataSet.Table_forage_famille)
        Me.Table_historiqueTableAdapter.Fill(Me.DboutillageDataSet.Table_historique)
 
        ' Variable de table : table actu & table historique'
        ma_table = DboutillageDataSet.Table_forage_famille.TableName
        ma_table_adaptater = Table_forage_familleTableAdapter
        ma_table_histo = DboutillageDataSet.Table_historique.TableName
        ma_table_histo_adaptater = Table_historiqueTableAdapter
 
 
    End Sub
Et lorsque je décide d'ajouter une colonne ou de supprimer ça marche niquel. Cependant quand je supprime plusieurs colonnes ou j'ajoute et je supprime (enfin je m'amuse avec ma BDD) là c'est le drame ! Il cri :
"cuncurrency violation : the deletcommad affected 0 of the 1 expected 1 records"
Alors je me dis c'est surement un soucis du datagrid qui n'est pas réinitialisé ! Mais alors impossible de le relancer mise a part un clear total ?


voici mon code ajout/suppr/save

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 Private Sub btn_save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_save.Click
        'DboutillageDataSet = DboutillageDataSet.GetChanges()
        Fonctions_validation_historique.ShowDialog()
        Dim verif_bool As Boolean
 
        verif_bool = Fonctions_validation_historique.Get_verification()
 
        If verif_bool = True Then
            fonction_sauvegarde_table(DboutillageDataSet.Table_forage_famille, Table_forage_familleTableAdapter, ma_table)
 
 
        Else
            MsgBox("La sauvegarde de la table n'a pas été effectuée")
        End If
 
    End Sub
 
 
 
Private Sub btn_ajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ajouter.Click
 
        Try
            Me.TableforagefamilleBindingSource.AllowNew = True
            Me.TableforagefamilleBindingSource.AddNew()
 
        Catch except As Exception
            MessageBox.Show("la valeur indiquée ne corresponds pas aux attentes demandées")
        End Try
 
    End Sub
Private Sub btn_supprimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_supprimer.Click
 
 
        Fonctions_validation_historique.ShowDialog()
        Dim verif_bool As Boolean
 
        verif_bool = Fonctions_validation_historique.Get_verification()
 
        If verif_bool = True Then
            Try
                Dim strMessage As String
                Dim slbl As String
                slbl = Trim(Table_forage_familleDataGridView.CurrentRow.Cells(0).Value)
                slbl = Trim(slbl)
                strMessage = String.Format("Désirez-vous supprimer {0} ?", slbl)
 
                If MessageBox.Show(strMessage, "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then
                    Try
 
                        ma_table_adaptater.Delete(slbl)
                        Fonctions_validation_historique.fonction_sauvegarde_validation_formulaire(ma_table)
                        Table_forage_familleTableAdapter.Update(DboutillageDataSet.Table_forage_famille)
                        MessageBox.Show("Suppresion réussi")
                        TableforagefamilleBindingSource.RemoveCurrent()
                        'DboutillageDataSet = DboutillageDataSet.GetChanges()
                        'boutillageDataSet.GetChanges()
 
                    Catch ex As Exception
                        MessageBox.Show("Erreur rencontrée : " & ex.Message.ToString)
                    End Try
                Else
                    '
                End If
            Catch ex As Exception
            End Try
        Else
            MsgBox("L'action n'a pas été effectuée")
        End If
    End Sub

et voici la fonction sauvegarde :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  Public Sub fonction_sauvegarde_table(ByVal nom_table, ByVal nom_table_adaptater, ByVal ma_table)
 
        If MessageBox.Show("Désirez-vous enregistrer la table actuelle", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then
            Try
 
 
                Fonctions_validation_historique.fonction_sauvegarde_validation_formulaire(ma_table)
                nom_table_adaptater.Update(nom_table)
                MsgBox("Validation effectuée")
            Catch ex As Exception
                MessageBox.Show("Erreur rencontrée : " & ex.Message.ToString)
            End Try
        End If
 
    End Sub
Merci à tous !