Bonjour !

Voilà, j'ai tenté un if, mais il va directement dans Else... Quoique je fasse...
Même si les conditions sont remplies... Savez vous pq ? Merci !

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
73
74
75
76
77
78
Protected Sub btnRechercher_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRechercher.Click
        Dim StrConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Request.MapPath("..\App_Data") & "\BDGest_Client.mdb"
        Dim StrSQL As String
 
        If txtBoxNom.Text <> "" And txtBoxPrenom.Text <> "" Then
            StrSQL = "SELECT ID_Client FROM TClients WHERE Nom='"
            StrSQL += Replace(txtBoxNom.Text, "'", "''")
            StrSQL += "' AND Prenom='"
            StrSQL += Replace(txtBoxPrenom.Text, "'", "''")
            StrSQL += "'"
 
            Dim ObjConnection As New System.Data.OleDb.OleDbConnection(StrConnection)
            Dim ObjCommand As New System.Data.OleDb.OleDbCommand(StrSQL, ObjConnection)
            Dim ObjDataReader As System.Data.OleDb.OleDbDataReader
 
            Dim Int1 As Integer
            Dim Int2 As Integer
            Int1 = 0
            Try
                ObjConnection.Open()
                ObjDataReader = ObjCommand.ExecuteReader()
 
                Do While ObjDataReader.Read() = True
                    Int1 = Int1 + 1
                    Int2 = ObjDataReader("ID_Client")
                Loop
 
                If Int1 > 1 Then
                    Session("FgNom") = txtBoxNom.Text
                    Session("FgPrenom") = txtBoxPrenom.Text
                    Response.Redirect("GEST_CLIENT_RESULTAT_RECHERCHE.aspx")
                ElseIf Int1 = 0 Then
                    lblRecherche.Text = "Ce Client n'existe pas !"
                Else
                    Session("FgNumeroClient") = Int2
                    Response.Redirect("GEST_CLIENT_FICHE.aspx")
                End If
 
                ObjDataReader.Close()
                ObjConnection.Close()
 
            Catch ex As Exception
            End Try
        ElseIf txtBoxNumeroClient.Text <> "" Then
            StrSQL = "SELECT ID_Client FROM TClients WHERE ID_Client='"
            StrSQL += Replace(txtBoxNumeroClient.Text, "'", "''")
            StrSQL += "'"
 
            Dim ObjConnection As New System.Data.OleDb.OleDbConnection(StrConnection)
            Dim ObjCommand As New System.Data.OleDb.OleDbCommand(StrSQL, ObjConnection)
            Dim ObjDataReader As System.Data.OleDb.OleDbDataReader
 
            Dim Int1 As Integer
            Int1 = 0
            Try
                ObjConnection.Open()
                ObjDataReader = ObjCommand.ExecuteReader()
 
                Do While ObjDataReader.Read() = True
                    Int1 = Int1 + 1
                Loop
 
                If Int1 < 1 Then
                    lblRecherche.Text = "Ce Client n'existe pas !"
                Else
                    Session("FgNumeroClient") = txtBoxNumeroClient.Text
                    Response.Redirect("GESTION_CLIENT_FICHE.aspx")
                End If
 
                ObjDataReader.Close()
                ObjConnection.Close()
 
            Catch ex As Exception
            End Try
        Else
            lblRecherche.Text = "Votre recherche n'est pas complète ! Veuillez entrer un numéro de client ou son nom et son prénom !"
        End If
    End Sub