salut,

j'ai un petit prob pour effectuer une recherche multi critere

petit topo:

je recois comme arg ds une classe dbaccess : String n,String m,String t,int constr,int cli

et j'aimerais bien avec cela faire une instruction en fonction de l'etat du string ou de l'int

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
String instruction=("Select * from Vehicule where ");
 
		if (!numPlaque.equals(""))
		{
			instruction+="NUMEROPLAQUE_ID='"+numPlaque+"' and ";
		}
                if (!modele.equals(""))
		{
			instruction+="MODÈLE='"+modele+"' and ";
		}
                if (!typeCarburant.equals(""))
		{
			//instruction+="TYPECARBURANT='"+typeCarburant+"' and ";
 
		}
                if (Constructeur_id!=0)
                    instruction+="CONSTRUCTEUR_ID="+Constructeur_id+" and ";
 
                if (Client_id!=0)
                    instruction+="CLIENT_ID="+Client_id+";";

ca devient vite lourd, et ca plante a cause des "and"

y a t'il un moyen facile pour gerer une instruction? ou faut t'il faire tous les cas envisageable? :s
cad ici alors, plein de if en cascade pour traire les 5* cas??

merci