Bonjour , je suis complètement perdu et à cour de solutions et j'aimerais des pistes parce que je n'y arrive plus voilà mon soucis.

Contexte :
J'ai 6 Combobox : (CatégorieRadiologique_ComboBox_Home, CodeEtatFS_ComboBox_Home, Producteur_ComboBox_Home, Centre_ComboBox_Home, StationDestination_ComboBox_Home, Conditionnement_ComboBox_Home) sur une Form.

En fonction des choix de l'utilisateurs je dois effectuer une recherche dans ma base de données pour afficher des données dans une listview.
Cependant pour arriver à gérer plusieurs critères en même temps ma requête doit être adaptable.
Du style :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 ("SELECT FS , Radiologique , Lib_Code_Etat , Producteur , Centre , Station_Destination , Conditionnement " +
                    "FROM fiche " +
                    "JOIN ctg_rad ON fiche.ID_Rad = ctg_rad.ID_Rad " +
                    "JOIN etat ON fiche.Code_Etat = etat.Code_Etat  " +
                    "JOIN prod ON fiche.Code_Producteur = prod.Code_Producteur  " +
                    "JOIN site_centre ON fiche.Code_Centre = site_centre.Code_Centre " +
                    "JOIN station_destination ON fiche.Code_StationdeDestination = station_destination.Code_StationdeDestination " +
                    "JOIN statut_condition ON fiche.Code_Conditionnement = statut_condition.Code_Conditionnement WHERE " + PARTIE_DE_LA_REQUÊTE_ADAPTABLE, connection)
Cette partie de requête ( PARTIE_DE_LA_REQUÊTE_ADAPTABLE ) je l'ai appelée "REQUERY".
Maintenant voici mon code (du moins la partie concernée) :

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
70
71
72
 string REQUERY = "";
 
                string[] Index = new string[] { CatégorieRadiologique_ComboBox_Home.Text, CodeEtatFS_ComboBox_Home.Text, Producteur_ComboBox_Home.Text, Centre_ComboBox_Home.Text, StationDestination_ComboBox_Home.Text, Conditionnement_ComboBox_Home.Text };
                for (int i = 0; i < Index.Length; i++)
                {
                    if (Index[i] == CatégorieRadiologique_ComboBox_Home.Text)
                    {
                        if (CatégorieRadiologique_ComboBox_Home.Text == "")
                        {
                            REQUERY += REQUERY + "Radiologique =" + "'" + CatégorieRadiologique_ComboBox_Home.Text + "'";
                        }
                        else
                        {
                            REQUERY += REQUERY + " AND Radiologique =" + "'" + CatégorieRadiologique_ComboBox_Home.Text + "'";
                        }
                    }
                    else if (Index[i] == CodeEtatFS_ComboBox_Home.Text)
                    {
                        if (CodeEtatFS_ComboBox_Home.Text == "")
                        {
                            REQUERY += REQUERY + "Lib_Code_Etat =" + "'" + CodeEtatFS_ComboBox_Home.Text + "'";
                        }
                        else
                        {
                            REQUERY += REQUERY + " AND Lib_Code_Etat =" + "'" + CodeEtatFS_ComboBox_Home.Text + "'";
                        }
                    }
                    else if (Index[i] == Producteur_ComboBox_Home.Text)
                    {
                        if (Producteur_ComboBox_Home.Text == "")
                        {
                            REQUERY += REQUERY + "Producteur =" + "'" + Producteur_ComboBox_Home.Text + "'";
                        }
                        else
                        {
                            REQUERY += REQUERY + " AND Producteur =" + "'" + Producteur_ComboBox_Home.Text + "'";
                        }
                    }
                    else if (Index[i] == Centre_ComboBox_Home.Text)
                    {
                        if (Centre_ComboBox_Home.Text == "")
                        {
                            REQUERY += REQUERY + "Centre =" + "'" + Centre_ComboBox_Home.Text + "'";
                        }
                        else
                        {
                            REQUERY += REQUERY + " AND Centre =" + "'" + Centre_ComboBox_Home.Text + "'";
                        }
                    }
                    else if (Index[i] == StationDestination_ComboBox_Home.Text)
                    {
                        if (StationDestination_ComboBox_Home.Text == "")
                        {
                            REQUERY += REQUERY + "Station_Destination =" + "'" + StationDestination_ComboBox_Home.Text + "'";
                        }
                        else
                        {
                            REQUERY += REQUERY + " AND Station_Destination =" + "'" + StationDestination_ComboBox_Home.Text + "'";
                        }
                    }
                    else if (Index[i] == Conditionnement_ComboBox_Home.Text)
                    {
                        if (CatégorieRadiologique_ComboBox_Home.Text == "")
                        {
                            REQUERY += REQUERY + "Conditionnement =" + "'" + Conditionnement_ComboBox_Home.Text + "'";
                        }
                        else
                        {
                            REQUERY += REQUERY + " AND Conditionnement =" + "'" + Conditionnement_ComboBox_Home.Text + "'";
                        }
                    }
                }
En gros ce que je souhaite faire :
-Tu parcours le tableau
- Pour chaque ligne tu vérifie de quelle combobox on parle
- Si on parle de la combobox ABC alors tu rentre dans la condition et dans cette condition. Si la variable REQUERY est vide alors tu ajoute "AND ...." (Sinon tu ajoute mais sans le AND) et tu passe à la ligne du tableau suivante ( i++) et tu recommence de sorte à traiter toutes lignes afin de construire le WHERE de la requête REQUERY . Mais ça ne marche pas , il ne passe pas à la ligne d'après.

Pouvez vous m'aider ? Besoin de plus d'info ?

""#############""
MERCI D'AVANCE
""#############""