Unhandled exception of type 'system.data.sqlclient.sqlexception'

Fermé
jakbauer222 Messages postés 15 Date d'inscription lundi 30 mars 2009 Statut Membre Dernière intervention 13 mars 2017 - Modifié par jakbauer222 le 13/03/2017 à 15:06
michel_m Messages postés 16603 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2023 - 14 mars 2017 à 08:14
Imports System.Data.SqlClient
Public Class Supprimer_Produit
Dim Cn As New SqlConnection("Data Source=(localdb)\Projects;Initial Catalog=gestion;Integrated Security=True")
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Cn.Open()
Dim cmd As New SqlCommand("delete from Produit where idP=" & Val(ComboBox1.Text), Cn)


cmd.ExecuteNonQuery()
Cn.Close()

Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "etes vous sùre de vouloir supprimer ce produit !!"
style = MsgBoxStyle.DefaultButton2 Or _
MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
title = "MsgBox Démonstration"
response = MsgBox(msg, style, title)
If response = MsgBoxResult.Yes Then
MsgBox("Produit Supprimé avec succés", 0 + 64, "1)") '
listes_Produits.Show()
Me.Close()
Else

Me.Show()
End If
End Sub

Private Sub Supprimer_Produit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cn.Open()
Dim cmd As New SqlCommand()
cmd.CommandText = "select idP from Produit"
cmd.CommandType = CommandType.Text
cmd.Connection = Cn
Dim Dr As SqlDataReader = cmd.ExecuteReader()
While Dr.Read
ComboBox1.Items.Add(Dr.Item(0))
End While
Dr.Close()
Cn.Close()
End Sub
End Class










Voila mon code ci dessus sv je veux de l'assistance unhandled exception of type 'system.data.sqlclient.sqlexception' occurred in system.data.dll

1 réponse

michel_m Messages postés 16603 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2023 3 312
14 mars 2017 à 08:14
1