Salut a tous , J'ai une table " Facture " que je remplis la première fois ,
la 2 fois je veux supprimer les enregistrements précédents et insérer d'autres , c'est la ou je bloque dans le deuxième passage , la table se vide , mais la réinsertion échoue et aucune donnée n'est insérer
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
  str = New StreamReader(openfile.FileName)
        ligne = str.ReadLine
        Dim id_agence As Integer = 1
 
        If GEDDataSet2.Tables("facture").Rows.Count <> 0 Then
            FactureTableAdapter2.DeleteQuery()
 
        End If
 
        While ligne <> ""
            dr = Nothing
            dr = GEDDataSet2.Tables("facture").NewRow
 
            dr("n_facture") = Val(Getnumfacture(ligne))
            dr("n_contrat") = Val(GetNumContrat(ligne))
            dr("id_agence") = id_agence
            dr("codebarre") = Getcodebarre(ligne)
            dr("annee") = Getannee(ligne)
            dr("mois") = Getmois(ligne)
            dr("consommation") = Getconsommation(ligne)
            dr("total_ht") = Gettotal_ht(ligne)
            dr("total_tva") = Gettotal_tva(ligne)
            dr("tournee") = Gettournee(ligne)
            dr("solde_anterieur") = Getsolde_anterieur(ligne)
            dr("consommation_facture") = Getconsommation_facture(ligne)
            dr("index_1") = Getindex_1(ligne)
            dr("index_2") = Getindex_2(ligne)
            dr("page") = page
            Try
                dr("db") = CDate(Getdatedebut(ligne))
                dr("df") = CDate(Getdatefin(ligne))
                dr("date_limite_paiement") = CDate(Getdate_limite_paiement(ligne))
                GEDDataSet2.Tables("facture").Rows.Add(dr)
 
                FactureTableAdapter2.InsertQuery(Val(Getnumfacture(ligne)), Val(GetNumContrat(ligne)), id_agence, Getcodebarre(ligne), Getannee(ligne),
                                             Getmois(ligne), Getconsommation(ligne), CDate(Getdatedebut(ligne)), CDate(Getdatefin(ligne)), page, Gettotal_ht(ligne),
                                             Gettotal_tva(ligne), CDate(Getdate_limite_paiement(ligne)), Gettournee(ligne), Getsolde_anterieur(ligne),
                                             Getconsommation_facture(ligne), Getindex_1(ligne), Getindex_2(ligne)
                                                                                                       )
 
                FactureDataGridView.Refresh()
 
            Catch fac As Exception
            End Try
 
            ligne = str.ReadLine
            page += 1
            id_agence += 1
 
        End While