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 :

Affichage de donnée DataGridView par Access


Sujet :

VB.NET

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut Affichage de donnée DataGridView par Access
    Bonsoir

    je suis entrain de faire une appli en VB et j'ai lié à mon application une base de donnée que j'ai fais sous access.

    Une fois la connexion effectué grâce à Visual Basic Express 2008, j'aimerais afficher le résultat d'une requête "SELECT * FROM Table1" dans un DataGridView

    Or je ne sais pas comment faire... est-ce quelqu'un peut m'aider ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Table1TableAdapter.Fill(Me.FollowflashDataSet.Table1)
        End Sub
     
    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
     
        End Sub
    Je vous remercie

  2. #2
    Membre expérimenté

    Profil pro
    Inscrit en
    Février 2005
    Messages
    14
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 14
    Points : 1 439
    Points
    1 439
    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
    Dim Connection As New OleDb.OleDbConnection()
    Dim AdapTContact As OleDb.OleDbDataAdapter
    Dim DtSet As New DataSet()
    Dim Sql As string
     
    'Parametrage de la chaine de connection
    Connection.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & _
    "data source= " & Application.StartupPath & "\" & "tnombdd.mdb;"
     
    ‘ouverture de la connection
    Connection.Open()
     
    ‘definition de la requete
    Sql="select * from nomtable", Connection
     
    ‘definition du DataAdapter
    AdapTContact=new OleDbDataAdapter (Sql, connection)
     
    ' remplissage du dataset
    AdapTContact.Fill(DtSet, "nomtable")
     
    ‘Fermeture de la connection
    Connection.Close()
     
      Dim Matable As DataTable
    Matable = DtSet.Tables("nomtable")
    DatagridView.DataSource = Matable

  3. #3
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    Sa fonctionne ce que tu a fait ??
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Table1TableAdapter.Fill(Me.FollowflashDataSet.Table1)
        End Sub
     
    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
     
        End Sub
    Je ne met pas en doute ce que tu a fait mais sa me parais tellement simple que sa m'étonne
    (je me suis galérer pour établir une connections avec ma base Acces ... )

    Juste pour faire une requête SQL c'est simple:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    "SELECT table1.* FROM table1"
    'ou en plus complet
    "SELECT table1.* FROM table1 ORDER BY MaColonne1"
    mais ou la mettre avec ton code et quand l'appeler je ne saurais pas trop te dire ...

    Tu peu essayer datagridView.dataSource() et mettre le chemin d'accès dans les ()

  4. #4
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    non évidemment ca ne fonctionne pas, je montrais simplement ce que j'avais à la base,

    en tous cas je remercie selkis pour sa réponse ultra complète,

    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
     Private Sub Fonction()
            Dim Connection As New OleDb.OleDbConnection()
            Dim AdapTContact As OleDb.OleDbDataAdapter
            Dim DtSet As New DataSet()
            Dim Sql As String
     
            'Parametrage de la chaine de connection
            Connection.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & _
            "data source= " & Application.StartupPath & "\" & "followflash.accdb;"
     
            'ouverture de la connection
            Connection.Open()
     
            'definition de la requete
            Sql = "select * from Table1"
     
            'definition du DataAdapter
            AdapTContact = New OleDb.OleDbDataAdapter(Sql, Connection)
     
            ' remplissage du dataset
            AdapTContact.Fill(DtSet, "Table1")
     
            'Fermeture de la connection
            Connection.Close()
     
            Dim Matable As DataTable
            Matable = DtSet.Tables("Table1")
            DataGridView1.DataSource = Matable
        End Sub
     
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO*: cette ligne de code charge les données dans la table 'FollowflashDataSet.Table1'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
            Me.Table1TableAdapter.Fill(Me.FollowflashDataSet.Table1)
            Fonction()
        End Sub
    Mais sa ne fonctionne pas... j'ai toujours rien dans mon DataGridView

    EDIT1 : j'ai trouvé pourquoi, je suis sous windows 7 x64 et ce n'est pas géré en 64 bits j'ai donc du procéder de la manière suivante :

    Dans Outils / Options cliquez sur "Affichez tous les paramètres" en bas à gauche.
    Dans l'arbrescence, sélectionnez "Projets et solutions/Général".
    Activez l'option : "Afficher les configurations de génération avancées"
    Dans le menu Générer / Gestionnaire de configuration.
    Dans la liste déroulante "Plateforme de la solution active" choisissez : "Nouveau".
    Dans la liste déroulante "Tapez ou sélectionnez la nouvelle plateforme", choissez : "x86" et cliquez sur "OK".
    Vérifiez que la plateforme "x86" est sélectionnée dans la liste de vos projets.

  5. #5
    Membre du Club
    Inscrit en
    Mars 2010
    Messages
    90
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 90
    Points : 60
    Points
    60
    Par défaut
    Citation Envoyé par alexandre01 Voir le message
    Bonsoir


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Table1TableAdapter.Fill(Me.FollowflashDataSet.Table1)
        End Sub
     
        End Sub
    ca devrait marcher normalement ce code est ce qui t'es sur que ton dataset contient les données de ta tables???

    sinon essaye avec ce code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     strQuery = "SELECT * FROM table1"
     
                myCommand.CommandText = strQuery
                dr = myCommand.ExecuteReader()
     
     
                While dr.Read()
                    DataGridView2.Rows.Add(dr(0), dr(1), dr(5), ............)
                End While

  6. #6
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    Oui Oui en faite ca fonctionnait c'est juste que mon code était compilé en 64bits (je suis sous windows 7 x64) et dans les paramètre de compilation j'ai indiqué x86 et maintenant ca fonctionne.

    Maintenant je cherche à ajouter une entrée dans ma Table avec des champs texte que je remplis

  7. #7
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Dim tonConnecteurBDD As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source = followflash.accdb")
                    tonConnecteurBDD.Open()
                    Dim taCommandeSQL As String = "Insert INTO Table1 VALUES('','var','var1','var','var','var','var','var','var','var','var','var','var');"
                    Dim maCommande As OleDb.OleDbCommand = New OleDb.OleDbCommand(taCommandeSQL, tonConnecteurBDD)
                    maCommande.ExecuteNonQuery()
                    tonConnecteurBDD.Close()
    Je n'ai aucune erreur mais l'entrée n'est pas ajouté à ma table pourquoi ?

  8. #8
    Membre du Club
    Inscrit en
    Mars 2010
    Messages
    90
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 90
    Points : 60
    Points
    60
    Par défaut
    c'est quoi var??? ce son les valeurs des textbox que tu récupère??

    sinon t'a pas mentionné les champs de la table je crois



    voici une requête qui fonctionne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    strQuery1 = "insert into llx_product(ref,label,stock) values ('" & TextBox3.Text & "', '" & TextBox1.Text & "','" & TextBox2.Text & "')  "
                    myCommand1.Connection = conn1
                    myCommand1.CommandText = strQuery1
                    myCommand1.ExecuteNonQuery()

  9. #9
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    voici mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     Dim tonConnecteurBDD As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=followflash.accdb")
                    tonConnecteurBDD.Open()
     
                    Dim taCommandeSQL As String = "Insert INTO Table1 (NOM,PRENOM,MAIL,TEL,CONSOLE,MODELE,SERIAL,LECTEUR,INTERVENTION,TARIF,DATE_INTER,PAYE) VALUES('var','var1','var','var','var','var','var','var','var','50','10/01/1998','var')"
                    Dim maCommande As OleDb.OleDbCommand = New OleDb.OleDbCommand(taCommandeSQL, tonConnecteurBDD)
                    maCommande.CommandText = taCommandeSQL
                    maCommande.ExecuteNonQuery()
     
                    tonConnecteurBDD.Close()
                    MsgBox("C'est ajouté !")
    'var' étant simplement pour tester si ca va mettre 'var' dans ma table or la ce n'est pas le cas...

    Sa ne m'ajoute rien dans ma table... pourquoi ?

    j'ai résolus !

    j'ai rajouté maCommande.connection = tonConnecteurBDD !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     Dim tonConnecteurBDD As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=followflash.accdb")
                    tonConnecteurBDD.Open()
     
                    Dim taCommandeSQL As String = "Insert INTO Table1 (NOM,PRENOM,MAIL,TEL,CONSOLE,MODELE,SERIAL,LECTEUR,INTERVENTION,TARIF,DATE_INTER,PAYE) VALUES('var','var1','var','var','var','var','var','var','var','50','10/01/1998','var')"
                    Dim maCommande As OleDb.OleDbCommand = New OleDb.OleDbCommand(taCommandeSQL, tonConnecteurBDD)
    maCommande.connection = tonConnecteurBDD
                    maCommande.CommandText = taCommandeSQL
                    maCommande.ExecuteNonQuery()
     
                    tonConnecteurBDD.Close()
                    MsgBox("C'est ajouté !")
    maintenant est-ce que vous pouvez dire comment supprimer de la table une entrée sélectionnée dans un GridDataView ?

    Merci

  10. #10
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    bon bein non ca ne fonctionne pas...

    j'ai réussi tout a l'heure je ne sais pas comment j'ai fais... la impossible...

    aucune erreur ni SQL ni VB et ca veut pas s'ajouter dans ma table...

    voici le code :

    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
      Dim tonConnecteurBDD As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=followflash.accdb;")
     
     
                    tonConnecteurBDD.Open()
     
                    Dim taCommandeSQL As String = "Insert INTO Table1 (NOM,PRENOM,MAIL,TEL,CONSOLE,MODELE,SERIAL,LECTEUR,INTERVENTION,TARIF,DATE_INTER,PAYE) VALUES('var','var1','var','var','var','var','var','var','var','50','10/01/1998','var')"
                    Dim maCommande As OleDb.OleDbCommand = New OleDb.OleDbCommand(taCommandeSQL, tonConnecteurBDD)
                    'Try
                    maCommande.Connection = tonConnecteurBDD
                    maCommande.CommandText = taCommandeSQL
                    maCommande.ExecuteNonQuery()
     
                    ' Catch ex As Exception
                    'MessageBox.Show(ex.ToString, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    ' End Try
     
                    tonConnecteurBDD.Close()
                    MsgBox("C'est ajouté !")
    si sa continu je vais me jeter par la fenêtre.... c'est entrain de me mettre au bout du rouleau...

  11. #11
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    Je n'ais pas travaillé comme toi
    j'ais directement ajouté des lignes dans le DataSet puis je l'ais a jour à chaque fois
    (mais a voir si tu utilise un DataSet ou aute chose la je sais pas aprés ...)

    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
            '################################################################
            '################ Enregistrement des Dimensions #################
            '################################################################
     
            'Ajout d'une ligne dans l'objetdata
            ObjetDataRowTblDim = ObjetDataSetTblDim.Tables("tblDimensions").NewRow()
            ' On rempli les champs dans l'objetData
            ObjetDataRowTblDim("NumCoupure") = LastNumCoupure + 1
            ObjetDataRowTblDim("NomCoupure") = Nomcoupure
            ObjetDataRowTblDim("CodeProduit") = CodeProduit
            ObjetDataRowTblDim("LargeurPalette") = LargeurPalette
            ObjetDataRowTblDim("LongueurPalette") = LongueurPalette
            ObjetDataRowTblDim("HauteurPalette") = HauteurPalette
            ObjetDataRowTblDim("LargeurBoite") = LargeurBoite
            ObjetDataRowTblDim("LongueurBoite") = LongueurBoite
            ObjetDataRowTblDim("HauteurBoite") = HauteurBoite
            'On remplie la ligne ajoutée dans l'objetData
            ObjetDataSetTblDim.Tables("tblDimensions").Rows.Add(ObjetDataRowTblDim)
            'Pour modifier les valeurs changées dans le DataAdapter
            ObjetCommandBuilder = New OleDbCommandBuilder(ObjetDataAdapterTblDim)
            'Mise à jour
            ObjetDataAdapterTblDim.Update(ObjetDataSetTblDim, "tblDimensions")
            'On vide le DataSet et on le 'recharge' de nouveau
            ObjetDataSetTblDim.Clear()
            ObjetDataAdapterTblDim.Fill(ObjetDataSetTblDim, "tblDimensions")
     
     
     
            ObjetConnection.Close()
    *En espérant que sa puisse t'aider un peut*

  12. #12
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    merci mais j'arrive pas à adapter ton code au mien...

  13. #13
    Membre du Club
    Inscrit en
    Mars 2010
    Messages
    90
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 90
    Points : 60
    Points
    60
    Par défaut
    Citation Envoyé par alexandre01 Voir le message
    voici mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     Dim tonConnecteurBDD As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=followflash.accdb")
                    tonConnecteurBDD.Open()
     
                    Dim taCommandeSQL As String = "Insert INTO Table1 (NOM,PRENOM,MAIL,TEL,CONSOLE,MODELE,SERIAL,LECTEUR,INTERVENTION,TARIF,DATE_INTER,PAYE) VALUES('var','var1','var','var','var','var','var','var','var','50','10/01/1998','var')"
                    Dim maCommande As OleDb.OleDbCommand = New OleDb.OleDbCommand(taCommandeSQL, tonConnecteurBDD)
                    maCommande.CommandText = taCommandeSQL
                    maCommande.ExecuteNonQuery()
     
                    tonConnecteurBDD.Close()
                    MsgBox("C'est ajouté !")
    'var' étant simplement pour tester si ca va mettre 'var' dans ma table or la ce n'est pas le cas...

    Sa ne m'ajoute rien dans ma table... pourquoi ?

    j'ai résolus !

    j'ai rajouté maCommande.connection = tonConnecteurBDD !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     Dim tonConnecteurBDD As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=followflash.accdb")
                    tonConnecteurBDD.Open()
     
                    Dim taCommandeSQL As String = "Insert INTO Table1 (NOM,PRENOM,MAIL,TEL,CONSOLE,MODELE,SERIAL,LECTEUR,INTERVENTION,TARIF,DATE_INTER,PAYE) VALUES('var','var1','var','var','var','var','var','var','var','50','10/01/1998','var')"
                    Dim maCommande As OleDb.OleDbCommand = New OleDb.OleDbCommand(taCommandeSQL, tonConnecteurBDD)
    maCommande.connection = tonConnecteurBDD
                    maCommande.CommandText = taCommandeSQL
                    maCommande.ExecuteNonQuery()
     
                    tonConnecteurBDD.Close()
                    MsgBox("C'est ajouté !")
    maintenant est-ce que vous pouvez dire comment supprimer de la table une entrée sélectionnée dans un GridDataView ?

    Merci
    pour l'insertion essaye de faire la requete via accès a fin de vérifier si elle passe sinon y'a rien qui cloche normalement

    je te donne le code complet sous mysql
    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
      Dim conn1 As MySqlConnection
     
            conn1 = New MySqlConnection()
            conn1.ConnectionString = "Data Source= localhost;user id= utilisa ;password=1234;database=dolib"
     
            Try
                conn2.Open()
     
                Dim myCommand1 As New MySqlCommand
     
     
                Dim strQuery1 As String
                strQuery1 = "insert into llx_product(ref,label,stock) values ('" & TextEdit3.Text & "', '" & TextEdit1.Text & "','" & TextEdit2.Text & "')  "
                myCommand1.Connection = conn1
                myCommand1.CommandText = strQuery1
                myCommand1.ExecuteNonQuery()
    sinon pour le datagridview:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    'tu récupere l'index de ton dataveiw
       Dim i, pos As Integer
                For i = 0 To Me.DataGridView1.Rows.Count - 1
                    If Me.DataGridView1.Rows.Item(i).Selected Then
                        pos = i
     
                    End If
                Next
    ' par la suite tu fait une requete simple
     
    delete from table where x='" & me.datagridview(0,(pos)).value &"'
    'ps: 0 représente l'index de la première colonne

  14. #14
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    merci pour ta réponse,

    le datagridview fonctionne lui, et ma requête je l'ai testé dans visual basic express et mes données sont bien ajoutées à ma BD, sauf que quand je clique sur le bouton Ajouter de mon forme, sa veut pas exécuter ma requête !

    n'y a t'il pas moyen de voir si ca me renvoi une erreur SQL ou autre ?

  15. #15
    Membre du Club
    Inscrit en
    Mars 2010
    Messages
    90
    Détails du profil
    Informations forums :
    Inscription : Mars 2010
    Messages : 90
    Points : 60
    Points
    60
    Par défaut
    dans ce cas vérifie ton code le problème est surement la !!! ou alors t'a changer l'évènement de ton bouton

    Bonne chance

  16. #16
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    déjà vérifié, l'event de mon boutton est bien "click" et puis j'ai bien la msgbox qui s'affiche donc...

    Aucune modification je ne comprend pas... j'arrive au bout du rouleau...

  17. #17
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    j'ai trouvé d'où vient le problème : mon datasource

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Dim tonConnecteurBDD As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source = C:\Users\Alex\Documents\Visual Studio 2008\Projects\Follow Flash\Follow Flash\followflash.accdb; Persist Security Info=False;")
    avec le chemin absolue vers la base de donnée, cela fonctionne, si je met simplement followflash.accdb cela ne fonctionne pas.

    est-ce que cela ne vas pas poser problème lors du compilage ?

  18. #18
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2006
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Tourisme - Loisirs

    Informations forums :
    Inscription : Août 2006
    Messages : 61
    Points : 26
    Points
    26
    Par défaut
    est-ce que quelqu'un peut me dire comment je retourne l'ID (contenu dans ma base de donnée access) d'un élément que je sélectionne dans un DataGridView dans lequel j'affiche mes données de ma BD ?

    edit1 :

    c'est bon :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     Dim idf As String = DataGridView1.CurrentRow.Cells(0).Value.ToString
    Par contre n'y a t'il pas la possibilité d'actualisé le datagridview ? car l'entrée est bien supprimée mais le datagridview ne se met pas a jour,

    je suis obligé de fermer le programme pour voir la modification.

Discussions similaires

  1. Réponses: 4
    Dernier message: 08/04/2013, 17h15
  2. affichage des données arabe en access
    Par rose2009 dans le forum JDBC
    Réponses: 0
    Dernier message: 03/08/2009, 18h29
  3. [ Problème d'affichage de données ligne par ligne ]
    Par Arkoze dans le forum VB 6 et antérieur
    Réponses: 6
    Dernier message: 05/06/2007, 09h45

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