Salut !
Je voulais savoir comment faire un update.
J'ai pour exemple une table "Produit" avec Colonnes "nom, foto"
Au moment de lancer le update il me vérifie qu'il n'y a pas de produit avec le meme nom.
Sauf que que veux changer la photo du produit et évidement comme le produit existe il me le dit.
Y'a t'il moyen de contourne ce problème ?
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 If TextBox7.Text = 1 Then 'Guardar Imagen' Dim mstream As New System.IO.MemoryStream() PictureBox1.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Png) Dim arrImage() As Byte = mstream.GetBuffer() mstream.Close() 'Guardar Imagen' If READER.HasRows Then MsgBox("Product Duplicated !", MsgBoxStyle.Critical) Me.Show() MysqlConn.Close() Else Try MysqlConn.Open() COMMAND.Connection = MysqlConn COMMAND.CommandText = "update product set name=@Value3, foto=@foto where id = '" & TextBox1.Text & "'" COMMAND.Parameters.AddWithValue("@Value3", If(String.IsNullOrEmpty(TextBox2.Text), DBNull.Value, TextBox2.Text)) COMMAND.Parameters.AddWithValue("@foto", arrImage) READER = COMMAND.ExecuteReader MessageBox.Show("Datos Guardados") MysqlConn.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally MysqlConn.Dispose() End Try
Partager