1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Dim cmd As SqlCommand = New SqlCommand("Select * from articles_design where idarticle =" & Val(Me.dgvDesignation.CurrentRow.Cells("idarticle").Value), cnx)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim ds As New DataSet
ds.Clear()
da.Fill(ds, "articles_design")
'récupère la clé de l'enregistrement sélectionné
Dim idArticle As String
idArticle = dgvDesignation.CurrentRow.Cells(0).Value.ToString
'recherche de la ligne a supprimer dans le DataSet
Dim Ligne As DataRow()
Ligne = ds.Tables("articles_design").Select("idarticle = " & idArticle)
'Suppression
Ligne(0).Delete()
Dim CmdBuild As SqlCommandBuilder
CmdBuild = New SqlClient.SqlCommandBuilder(da)
da.DeleteCommand = CmdBuild.GetDeleteCommand()
'Mise a jour avec la base
da.Update(ds, "articles_design")
'femeture de la connexion
Dim dt As DataTable
dt = ds.Tables("articles_design")
Me.dgvDesignation.DataSource = dt
Me.dgvDesignation.Refresh() |
Partager