Bonjour à tous,

Je suis entrain de faire des modifications sur des projets pour les cours et je me heurte a un probleme. J'ai plusieurs requete pour obtenir la liste de duplications, tant qu'il y la date issue du resultat de la requete sera le meme numero de jour que celui d'ajourd'hui on va inserer une date. Dans ma table je n'ai qu'un seul résultat qui correspond. Cependant au lancement de l'app, j'ai une boucle infinie qui me crée des insertions jsuqu'a ce que j'arrete le lancement. J'ai beau regardé le code long en large mais rien ... Pouvez vous m'aider ?
Merci d'avance

mrocks

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
        'Déclaration des variables de type OleDbCommand
        Dim MyCommand As OleDbCommand = MyConnexion.CreateCommand()
        Dim MyCommandMax As OleDbCommand = MyConnexion.CreateCommand()
        Dim MyCommandInsert As OleDbCommand = MyConnexion.CreateCommand()
        Dim MyCommandSelect As OleDbCommand = MyConnexion.CreateCommand()
 
        'Reader pour obtenir la liste des duplications où la fréquence de duplication est différent de "Unique"
        MyCommand.CommandText = "SELECT * FROM Duplication WHERE dup_frq <> 'Unique'"
        MyCommand.ExecuteNonQuery()
        Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader
 
        'Enregistrement des informations sur les duplications dans un tableau
        Dim nb_enr As Integer = 0
        Do While MyReader.Read()
            Dim tmp_jrs As Date = Today
            Dim tmp_jrs_today As Date = MyReader.GetValue(2)
 
            If (tmp_jrs.DayOfWeek = tmp_jrs_today.DayOfWeek) Then
 
                'Reader pour obtenir l'identifiant maximal utilisé
                MyCommandMax.CommandText = "SELECT MAX(dup_idt) FROM Duplication"
                MyCommandMax.ExecuteNonQuery()
 
                'Attribution d'une valeur à la variable "id_max"
                Dim MyReaderMax As OleDbDataReader = MyCommandMax.ExecuteReader
                Dim id_max As Integer
 
                Do While MyReaderMax.Read()
                    id_max = MyReaderMax.GetValue(0)
                Loop
                MyReaderMax.Close()
 
                'Execution de la réquete de duplication en fonction du "dup_frq"
                Select Case MyReader.GetValue(6)
                    Case "Quotidien"
                        MyCommandInsert.CommandText = "INSERT INTO Duplication VALUES ('" & (id_max + 1) & "', '" & MyReader.GetValue(1) & "', '" & MyReader.GetValue(2) & "', '" & MyReader.GetValue(2).AddDays(1) & "', '" & MyReader.GetValue(4) & "', '" & MyReader.GetValue(5) & "', '" & MyReader.GetValue(6) & "', '')"
                    Case "Hebdomadaire"
                        MyCommandInsert.CommandText = "INSERT INTO Duplication VALUES ('" & (id_max + 1) & "', '" & MyReader.GetValue(1) & "', '" & MyReader.GetValue(2) & "', '" & MyReader.GetValue(2).AddDays(7) & "', '" & MyReader.GetValue(4) & "', '" & MyReader.GetValue(5) & "', '" & MyReader.GetValue(6) & "', '')"
                    Case "Bimensuel"
                        MyCommandInsert.CommandText = "INSERT INTO Duplication VALUES ('" & (id_max + 1) & "', '" & MyReader.GetValue(1) & "', '" & MyReader.GetValue(2) & "', '" & MyReader.GetValue(2).AddDays(14) & "', '" & MyReader.GetValue(4) & "', '" & MyReader.GetValue(5) & "', '" & MyReader.GetValue(6) & "', '')"
                    Case "Mensuel"
                        MyCommandInsert.CommandText = "INSERT INTO Duplication VALUES ('" & (id_max + 1) & "', '" & MyReader.GetValue(1) & "', '" & MyReader.GetValue(2) & "', '" & MyReader.GetValue(2).AddMonths(1) & "', '" & MyReader.GetValue(4) & "', '" & MyReader.GetValue(5) & "', '" & MyReader.GetValue(6) & "', '')"
                End Select
                MyCommandInsert.ExecuteNonQuery()
 
            End If
 
        Loop
        MyReader.Close()