Bonjour tous !
Je dois faire un requête selon des conditions.
J'ai fais cette condition mais elle est trop longue, y-a-t-il une façon plus simple pour l'écrire:
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
 
       If nomtxt.Text <> "" Then
 
            sql = "SELECT Nom,Prenom,Libelle5 as Société,Photo from MSESAME.MS_BADGE WHERE Nom='" + nomtxt.Text + "'"
 
        ElseIf prentxt.Text <> "" Then
 
            sql = "SELECT Nom,Prenom,Libelle5 as Société,Photo from MSESAME.MS_BADGE WHERE Prenom='" + prentxt.Text + "'"
 
        ElseIf soctxt.Text <> "" Then
 
            sql = "SELECT Nom,Prenom,Libelle5 as Société,Photo from MSESAME.MS_BADGE WHERE Libelle5='" + soctxt.Text + "'"
 
        ElseIf nomtxt.Text <> "" And prentxt.Text <> "" Then
 
            sql = "SELECT Nom,Prenom,Libelle5 as Société,Photo from MSESAME.MS_BADGE WHERE Nom='" + nomtxt.Text + "' and Prenom='" + prentxt.Text + "'"
 
        ElseIf nomtxt.Text <> "" And soctxt.Text <> "" Then
 
            sql = "SELECT Nom,Prenom,Libelle5 as Société,Photo from MSESAME.MS_BADGE WHERE Nom='" + nomtxt.Text + "' and Libelle5='" + soctxt.Text + "'"
 
        ElseIf prentxt.Text <> "" And soctxt.Text <> "" Then
 
            sql = "SELECT Nom,Prenom,Libelle5 as Société,Photo from MSESAME.MS_BADGE WHERE Prenom='" + prentxt.Text + "' and Libelle5='" + soctxt.Text + "'"
 
        ElseIf nomtxt.Text <> "" And soctxt.Text <> "" And prentxt.Text <> "" Then
 
            sql = "SELECT Nom,Prenom,Libelle5 as Société,Photo from MSESAME.MS_BADGE WHERE Nom='" + nomtxt.Text + "' and Prenom='" + prentxt.Text + "' and Libelle5='" + soctxt.Text + "'"
 
        End If
prentxt, nomtxt et soctxt se sont des textbox.
Merci d'avance