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

VB.NET Discussion :

SELECT.. FROM.. WHERE.. AND.. AND.. !


Sujet :

VB.NET

  1. #21
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    OK je viens de le faire mais du coup la commande ObjetCommand1.ExecuteScalar je ne l'ai plus, la je n'ai rien de souligner...

    je pige pas il enregistre uniquement le 1er Do While myREADERnoFTP.Read()

  2. #22
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    j'ai résolu une partie du problème :

    j'ai remplacer l'
    *
    =>
    "SELECT * FROM Axes
    par le nom des champs maintenant ma table se remplit avec le nombre exacte d’élément mais il me copie la ligne 1 autant de fois qu'il fais un "while" pourtant je piège le résultat du myREADERnoFTP et il s’incrémente bien

    et lors de l'enregistrement ce n'est pas bon...

  3. #23
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    voici mon code à jour :

    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
        Public Sub selectAxeRUN()
     
            ObjetCommand.CommandText = "SELECT Nom_client, Num_client, Nom_axe, FDC_mini, FDC_maxi, statut, ftp FROM Axes WHERE ftp=No AND statut= @New "
            ObjetCommand.Parameters.Add("@New", OleDbType.VarChar).Value = "New"
     
            Dim noFTPaxes As OleDbDataReader = ObjetCommand.ExecuteReader()
     
            Do While noFTPaxes.Read()
     
                ObjetCommand1.CommandText = "SELECT Nom_client, Num_client, Nom_axe, FDC_mini, FDC_maxi, statut, ftp FROM Axes1 WHERE ((Nom_client = @Nom_client) AND (Num_client = @Num_client) AND (Nom_axe = @Nom_axe));"
                ObjetCommand1.Parameters.Add("@Nom_client", OleDbType.VarChar).Value = noFTPaxes.Item(1).ToString()
                ObjetCommand1.Parameters.Add("@Num_client", OleDbType.VarChar).Value = noFTPaxes.Item(2).ToString()
                ObjetCommand1.Parameters.Add("@Nom_axe", OleDbType.VarChar).Value = noFTPaxes.Item(3).ToString()
     
                Dim noFTPaxesFTP As OleDbDataReader = ObjetCommand1.ExecuteReader()
     
                If Not noFTPaxesFTP.HasRows Then
     
                    ObjetCommand2.CommandText = " INSERT INTO [Axes1] ( Nom_client, Num_client, Nom_axe, FDC_mini, FDC_maxi, statut, ftp )  VALUES ( @Nom_client, @Num_client, @Nom_axe, @FDC_mini, @FDC_maxi, @statut, @ftp );"
     
                    ObjetCommand2.Parameters.Add("@Nom_client", OleDbType.VarChar).Value = noFTPaxes.Item("Nom_client").ToString()
                    ObjetCommand2.Parameters.Add("@Num_client", OleDbType.VarChar).Value = noFTPaxes.Item("Num_client").ToString()
                    ObjetCommand2.Parameters.Add("@Nom_axe", OleDbType.VarChar).Value = noFTPaxes.Item("Nom_axe").ToString()
                    ObjetCommand2.Parameters.Add("@FDC_mini", OleDbType.VarChar).Value = noFTPaxes.Item("FDC_mini").ToString()
                    ObjetCommand2.Parameters.Add("@FDC_maxi", OleDbType.VarChar).Value = noFTPaxes.Item("FDC_maxi").ToString()
                    ObjetCommand2.Parameters.Add("@statut", OleDbType.VarChar).Value = "AJ"
                    ObjetCommand2.Parameters.Add("@ftp", OleDbType.Boolean).Value = True
     
                    ObjetCommand2.ExecuteNonQuery()
     
                End If
     
                noFTPaxesFTP.Close()
     
            Loop
     
            noFTPaxes.Close()
     
            ObjetConnection.Close()
        End Sub

  4. #24
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    je sélectionne bien le noFTPaxes.Item("Nom_client").ToString() de la première table pour le ObjetCommand2.CommandText = " INSERT INTO [Axes1]

    et non il me met que l'enregistrement 1 de la table axes dans la table axes1 et il me le met 50 fois comme j'ai 50 enregistrement dans la table axes

  5. #25
    Expert éminent sénior Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 154
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 154
    Points : 25 072
    Points
    25 072
    Par défaut
    il te manque

    ObjetCommand1.parameters.clear

    à côté du

    noFTPaxesFTP.Close

    ou alors faire un .add avant tout ca et ne faire varier que le .value


    explication :
    vu que tu n'as qu'une instance pour objetcommand1
    au 1er tour tu ajoutes 3 paramètres, au 2ème tour tu en ajoutes 3 autres (donc 6 inclus) etc...
    une fois de plus un bon sgbdr comme sql server t'aurais directement jeté avec un message d'erreur explicite mais access n'utilisant pas les noms des paramètres et les associant par ordre laisse faire n'importe quoi sans broncher mais avec le résultat que l'on voit ...

    un fois de plus access est à fuir ^^
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  6. #26
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    non c'est pareil j'ai toujours le même enregistrement qui se copie

  7. #27
    Expert éminent sénior Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 154
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 154
    Points : 25 072
    Points
    25 072
    Par défaut
    code ?
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  8. #28
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    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
        Public Sub selectAxeRUN()
     
            ObjetCommand.CommandText = "SELECT Nom_client, Num_client, Nom_axe, FDC_mini, FDC_maxi, statut, ftp FROM Axes WHERE ftp=No AND statut= @New "
            ObjetCommand.Parameters.Add("@New", OleDbType.VarChar).Value = "New"
     
            Dim noFTPaxes As OleDbDataReader = ObjetCommand.ExecuteReader()
     
            Do While noFTPaxes.Read()
     
                ObjetCommand1.CommandText = "SELECT Nom_client, Num_client, Nom_axe, FDC_mini, FDC_maxi, statut, ftp FROM Axes1 WHERE Nom_client = @Nom_client AND Num_client = @Num_client AND Nom_axe = @Nom_axe"
                ObjetCommand1.Parameters.Add("@Nom_client", OleDbType.VarChar).Value = noFTPaxes.Item(1).ToString()
                ObjetCommand1.Parameters.Add("@Num_client", OleDbType.VarChar).Value = noFTPaxes.Item(2).ToString()
                ObjetCommand1.Parameters.Add("@Nom_axe", OleDbType.VarChar).Value = noFTPaxes.Item(3).ToString()
     
                Dim noFTPaxesFTP As OleDbDataReader = ObjetCommand1.ExecuteReader()
                Dim resul As Integer = 0
     
                If Not noFTPaxesFTP.HasRows Then
     
                    ObjetCommand2.CommandText = " INSERT INTO [Axes1] ( Nom_client, Num_client, Nom_axe, FDC_mini, FDC_maxi, statut, ftp )  VALUES ( @Nom_client, @Num_client, @Nom_axe, @FDC_mini, @FDC_maxi, @statut, @ftp )"
     
                    ObjetCommand2.Parameters.Add("@Nom_client", OleDbType.VarChar).Value = noFTPaxes.Item("Nom_client").ToString()
                    ObjetCommand2.Parameters.Add("@Num_client", OleDbType.VarChar).Value = noFTPaxes.Item("Num_client").ToString()
                    ObjetCommand2.Parameters.Add("@Nom_axe", OleDbType.VarChar).Value = noFTPaxes.Item("Nom_axe").ToString()
                    ObjetCommand2.Parameters.Add("@FDC_mini", OleDbType.VarChar).Value = noFTPaxes.Item("FDC_mini").ToString()
                    ObjetCommand2.Parameters.Add("@FDC_maxi", OleDbType.VarChar).Value = noFTPaxes.Item("FDC_maxi").ToString()
                    ObjetCommand2.Parameters.Add("@statut", OleDbType.VarChar).Value = "AJ"
                    ObjetCommand2.Parameters.Add("@ftp", OleDbType.Boolean).Value = True
     
                    ObjetCommand2.ExecuteNonQuery()
     
                End If
     
                ObjetCommand1.Parameters.Clear()
                noFTPaxesFTP.Close()
     
            Loop
     
            noFTPaxes.Close()
     
            ObjetConnection.Close()
        End Sub

  9. #29
    Expert éminent sénior Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 154
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 154
    Points : 25 072
    Points
    25 072
    Par défaut
    c'est pareil pour objectcommand2

    vous avez donc modifié sans comprendre ce que j'ai dit ...
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  10. #30
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    sorry oui effectivement.. j'ai la tête un peux chaude ça me prend la tête depuis ce matin...

    l’équivalent en bdsql sa donnerait quoi ?

  11. #31
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    Merci pol63 de ton aide c'est parfait

  12. #32
    Expert éminent sénior Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 154
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 154
    Points : 25 072
    Points
    25 072
    Par défaut
    Citation Envoyé par tijote Voir le message
    l’équivalent en bdsql sa donnerait quoi ?
    c'est à dire ?
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  13. #33
    Membre régulier Avatar de jolona
    Homme Profil pro
    Technicien metodes
    Inscrit en
    Avril 2010
    Messages
    233
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Technicien metodes
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2010
    Messages : 233
    Points : 104
    Points
    104
    Par défaut
    est ce que mon code et requête serait différent ?

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 2 PremièrePremière 12

Discussions similaires

  1. Réponses: 2
    Dernier message: 08/09/2009, 11h41
  2. [COUNT] select ... from ... where count !
    Par tmcgrady dans le forum Langage SQL
    Réponses: 5
    Dernier message: 30/11/2007, 17h29
  3. probleme avec SELECT..FROM..WHERE
    Par VBBBA dans le forum Requêtes et SQL.
    Réponses: 8
    Dernier message: 08/09/2006, 15h58
  4. Pb de syntaxe sql : Sélection SELECT FROM WHERE vide
    Par oceanediana dans le forum Requêtes et SQL.
    Réponses: 8
    Dernier message: 31/07/2006, 15h54
  5. [hibernate][spring]requete select from where IN
    Par whilecoyote dans le forum Hibernate
    Réponses: 1
    Dernier message: 07/04/2006, 09h06

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