Erreur dans la syntax update en vb.net
safa
-
safa -
safa -
Bonjour,
j'ai un probleme de modification en vb.net .lorsque j'ai modifié un seul champ j'ai reçus cette erreur: "erreur dans la syntax update"
mais lors de la modification de tous les champs aucune erreur.
voiçi le code :
Cmdr = Cn.CreateCommand()
Cmdr.CommandText = "UPDATE produit SET code_produit=" & CType(TextBox6.Text, Integer) & ",designation='" & TextBox5.Text & "',quantité=" & TextBox7.Text & ",prix_unitaire=" & TextBox8.Text & ",tva=" & ComboBox2.Text & " where (code_produit=" & CType(Me.lv.SelectedItems(0).Text, Integer) & ")"
If Cmdr.ExecuteNonQuery() = 1 Then
MsgBox("modification fait avec succeé.", MsgBoxStyle.Information, "Modification de donnée")
End If
Call affichage()
j'ai un probleme de modification en vb.net .lorsque j'ai modifié un seul champ j'ai reçus cette erreur: "erreur dans la syntax update"
mais lors de la modification de tous les champs aucune erreur.
voiçi le code :
Cmdr = Cn.CreateCommand()
Cmdr.CommandText = "UPDATE produit SET code_produit=" & CType(TextBox6.Text, Integer) & ",designation='" & TextBox5.Text & "',quantité=" & TextBox7.Text & ",prix_unitaire=" & TextBox8.Text & ",tva=" & ComboBox2.Text & " where (code_produit=" & CType(Me.lv.SelectedItems(0).Text, Integer) & ")"
If Cmdr.ExecuteNonQuery() = 1 Then
MsgBox("modification fait avec succeé.", MsgBoxStyle.Information, "Modification de donnée")
End If
Call affichage()
1 réponse
-
Ajouter un point d'arrêt sur If Cmdr.ExecuteNonQuery() = 1 Then et copier ici la valeur de Cmdr
possible que c'est une erreur de textbox vide qui update un champ de table qui n'accepte pas la valeur vide ou null ...-
-
voila le code que j ai
If TextBox6.Text = "" Or TextBox5.Text = "" Or TextBox7.Text = "" Or TextBox8.Text = "" Or ComboBox2.Text = "" Then
MsgBox("veuillez remplir les champs", MsgBoxStyle.Exclamation, "Modification de donnée")
Exit Sub
Else
Cmdr = Cn.CreateCommand()
Cmdr.CommandText = "UPDATE produit SET code_produit=" & CType(TextBox6.Text, Integer) & ",designation='" & TextBox5.Text & "',quantité=" & TextBox7.Text & ",prix_unitaire=" & TextBox8.Text & ",tva=" & ComboBox2.Text & " where (code_produit=" & CType(Me.lv.SelectedItems(0).Text, Integer) & ")"
If Cmdr.ExecuteNonQuery() = 1 Then
MsgBox("modification fait avec succeé.", MsgBoxStyle.Information, "Modification de donnée")
End If
Call affichage()
End If
l erreur dans instruction update
les champs ne sont pas vide
l operation n affecte pas à un seul champ
mais pour tous les champs ça marche bien
-