IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

Problème fonction IF


Sujet :

ASP.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2007
    Messages : 15
    Par défaut Problème fonction IF
    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

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2007
    Messages : 15
    Par défaut
    J'ai ajouté juste avant le If :

    Response.Write("test")
    Response.Write(txtBoxNom.Text)
    Response.Write(txtBoxPrenom.Text)
    Response.End()

    Et tout ce à quoi j'ai droit c'est "test"...

  3. #3
    Rédacteur
    Avatar de SaumonAgile
    Homme Profil pro
    Team leader
    Inscrit en
    Avril 2007
    Messages
    4 028
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Team leader
    Secteur : Conseil

    Informations forums :
    Inscription : Avril 2007
    Messages : 4 028
    Par défaut
    Tu as vérifié que tes champs ne contenaient pas des espaces ?

    Essaie avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    !String.Empty.Equals(txtBoxNom.Text.Trim());
    Besoin d'un MessageBox amélioré ? InformationBox pour .NET 1.1, 2.0, 3.0, 3.5, 4.0 sous license Apache 2.0.

    Bonnes pratiques pour les accès aux données
    Débogage efficace en .NET
    LINQ to Objects : l'envers du décor

    Mon profil LinkedIn - MCT - MCPD WinForms - MCTS Applications Distribuées - MCTS WCF - MCTS WCF 4.0 - MCTS SQL Server 2008, Database Development - Mon blog - Twitter

Discussions similaires

  1. Problème : Fonctions et commande Execute
    Par bubi dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 15/11/2005, 11h01
  2. Problème fonction SDL
    Par seeme dans le forum SDL
    Réponses: 2
    Dernier message: 06/11/2005, 20h22
  3. Problème fonction PL/SQL
    Par SSJ17Vegeta dans le forum PL/SQL
    Réponses: 2
    Dernier message: 29/10/2005, 21h14
  4. Problème fonction et trigger sous 7.2
    Par anoukhan dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 22/06/2005, 22h53
  5. Réponses: 2
    Dernier message: 20/08/2004, 17h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo