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

Windows Forms Discussion :

Utilisation de ExecuteNonQuery()


Sujet :

Windows Forms

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2020
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : Congo-Kinshasa

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Février 2020
    Messages : 2
    Points : 3
    Points
    3
    Par défaut Utilisation de ExecuteNonQuery()
    Bonjour,

    j'ai tout respecté mais ça ne fonctionne toujours pas svp c'est un TP que l'on m'a donné aidez-moi on me donne le message d'executenonquery

    Code VB.NET : 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
    import System.Data.SqlClient
    Public Class ENREGISTREMENTS_DES_VISITEUR
        Public con As SqlConnection
        Public Sub connexion()
            Dim g As String = "Data Source=STLDB3\STLDB;Initial Catalog=VISITEURS;Integrated Security=True"
            con = New SqlConnection(g)
            con.Open()
        End Sub  
     
     
        Public Sub exection(ByVal sql As String)
            Dim e As SqlCommand = New SqlCommand
            connexion()
            e.Connection = con
            e.CommandType = CommandType.Text
            e.CommandText = sql
            e.ExecuteNonQuery()
            e.Dispose()
            con.Close()
            MsgBox("opération effectué avec succeés")
        End Sub
     
        Private Sub charger()
            connexion()
            Dim table As New DataTable
            Dim dtr3 As New SqlDataAdapter("select * FROM visiteur", con)
            dtr3.Fill(table)
            DataGridView1.DataSource = table
        End Sub
     
        Private Sub couleurdatagrid()
            With Me.DataGridView1
                .RowsDefaultCellStyle.BackColor = Color.DeepSkyBlue
                .AlternatingRowsDefaultCellStyle.BackColor = Color.Beige
            End With
        End Sub
     
        Private Sub enregistrer()
            Dim enregistrer As String
            enregistrer = "INSERT INTO visiteur (Numéro,Noms,Organisation ,Sexe,Télephone,Nature_Pièce,Numéro_Carte) VALUES ('" & TextBox5.Text.ToString & "','" & TextBox1.Text.ToString & "','" & TextBox2.Text.ToString & "','" & ComboBox1.Text.ToString & "','" & TextBox3.Text.ToString & "','" & ComboBox2.Text.ToString & "','" & TextBox4.Text.ToString & "')"
            exection(enregistrer)
            MsgBox("visiteur Enregistrer")
            TextBox5.Text = ""
            TextBox1.Text = ""
            TextBox2.Text = ""
            ComboBox1.Text = ""
            TextBox3.Text = ""
            TextBox2.Text = ""
            TextBox4.Text = ""
        End Sub
     
        Private Sub modification()
            Dim modif As String
            modif = " Update visiteur SET Numéro ='" & TextBox5.Text.ToString & "',Noms ='" & TextBox1.Text.ToString & "',Organisation ='" & TextBox2.Text.ToString & "',Sexe ='" & ComboBox1.Text.ToString & "',Télephone ='" & TextBox3.Text.ToString & "',Nature Pièce ='" & ComboBox2.Text.ToString & "' ,Numéro Carte ='" & TextBox4.Text.ToString & "' WHERE Numéro ='" & TextBox5.Text.ToString & "'"
            exection(modif)
            MsgBox("la modification est effectuer avec succes")
        End Sub
     
        Private Sub surprimer()
            Dim sup As String
            sup = "DELETE FROM  WHERE Numéro ='" & TextBox5.Text & "'"
            exection(sup)
            TextBox5.Text = ""
        End Sub
     
        Private Sub rechercher()
            If TextBox5.Text = "" Then
                MsgBox("le zone de recherche est vide")
            Else
                connexion()
                Dim table As New DataTable
                Dim dtr2 As New SqlDataAdapter("Select *  FROM visiteur where Numéro ='" + TextBox5.Text + "'", con)
                dtr2.Fill(table)
                DataGridView1.DataSource = table
                'se deconnecter()
            End If

  2. #2
    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
    quand on veut de l'aide la 1ère chose à faire est de bien expliquer le problème
    en l'occurrence quand on a une erreur, le minimum est de spécifier ce message (avec pourquoi pas la pile des appels, la ligne qui passe en erreur et le type de l'exception)
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

Discussions similaires

  1. Utilisation difficile de .executeNonQuery
    Par thomasaurelien dans le forum VB.NET
    Réponses: 17
    Dernier message: 15/12/2011, 16h32
  2. [VB.Net] Utilisation de ExecuteNonQuery()
    Par AcidX dans le forum Windows Forms
    Réponses: 3
    Dernier message: 16/05/2009, 16h08
  3. utilisation du meta type ANY
    Par Anonymous dans le forum CORBA
    Réponses: 1
    Dernier message: 15/04/2002, 12h36
  4. [BCB5] Utilisation des Ressources (.res)
    Par Vince78 dans le forum C++Builder
    Réponses: 2
    Dernier message: 04/04/2002, 16h01
  5. Réponses: 2
    Dernier message: 20/03/2002, 23h01

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