Bonjour a tous,

Je viens vers vous car j'ai un petit problème.
Je développe une moulinette vb6 qui traite deux fichiers différents et qui les insères dans une bdd Access.
Ceci marche parfaitement.

Cependant, j'ai écrit une fonction qui permet de regrouper des données. Ma fonction marche mais elle est trop longue (30 min par fichier). J'en ai trois a traiter. Donc Il faudrait que je réduise le temps.

Dans un premier temps je vous donne le code qui marche:
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
 
compteur = 0
    rstCotisationHR.MoveFirst
    While (Not rstCotisationHR.EOF)
        IDSalaireHR = rstCotisationHR.Fields("idSalaire").Value
        rstCotisationMSA.MoveFirst
        trouve = False
        While (Not rstCotisationMSA.EOF) And (trouve = False)
            If IDSalaireHR = rstCotisationMSA.Fields("idSalaire").Value Then
                If rstCotisationMSA.Fields("typeCotisationMSA").Value = rstCotisationHR.Fields("typeCotisationMSA").Value Then
                    rstCotisationMSA.Fields("typeCotisationHR").Value = rstCotisationHR.Fields("typeCotisationHR").Value
                    rstCotisationMSA.Fields("montantHR").Value = rstCotisationHR.Fields("montantHR").Value
                    trouve = True
                End If
            End If
            rstCotisationMSA.MoveNext
        Wend
        If trouve = False Then
            With rstCotisationMSA
                .AddNew
                .Fields("idSalaire").Value = IDSalaireHR
                .Fields("origine").Value = rstCotisationHR.Fields("origine").Value
                .Fields("typeCotisationMSA").Value = rstCotisationHR.Fields("typeCotisationMSA").Value
                .Fields("typeCotisationHR").Value = rstCotisationHR.Fields("typeCotisationHR").Value
                .Fields("montantHR").Value = rstCotisationHR.Fields("montantHR").Value
                .Fields("montantMSA").Value = 0
                .Update
             End With
        End If
        rstCotisationHR.MoveNext
        compteur = compteur + 1
        Label2.Caption = compteur
        Label2.Refresh
    Wend
Comment puis-je réduire le temps de traitement? Je pensais a faire directement en SQL? Qu'en pensez-vous?
Le problème, je ne connait le SQL mais le SQL plus poussé (comme la requête que je dois faire) est pour moi étranger (j'exagère un peu ^^).


PS: Le temps est si long car mon premier While (Not rstCotisationHR.EOF) boucle sur environ 15 000 enregistrements et mon second While (Not rstCotisationMSA.EOF) boucle sur environ 50 000 enregistrements. Comment puis-je faire? mise a part laisser tourner le PC 90 minutes?

Cordialement et bonne journée a tous.