ayuda con picture box
Publicado por pablo (52 intervenciones) el 19/09/2017 20:24:22
Buenas tardes
les hago una consulta , me pidieron en un programa que tengo que se puedan agregar imagenes y ahi esta el problema, logre agregar las imagenes a la base en acces, pero ahora solo me permite agregar un solo producto y al cargar el segundo tira el siguiente erro: "los cambios realizados en la tabla no se realizaron correctamentes porque crearina valores duplicados en el indice, clave principal etc "
este es el codigo que use para el agreado de imagens, si se les ocuure algo les agradeceria .Saludos
les hago una consulta , me pidieron en un programa que tengo que se puedan agregar imagenes y ahi esta el problema, logre agregar las imagenes a la base en acces, pero ahora solo me permite agregar un solo producto y al cargar el segundo tira el siguiente erro: "los cambios realizados en la tabla no se realizaron correctamentes porque crearina valores duplicados en el indice, clave principal etc "
este es el codigo que use para el agreado de imagens, si se les ocuure algo les agradeceria .Saludos
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Dim ms As New IO.MemoryStream
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
Dim i() As Byte = ms.GetBuffer
cmd.CommandType = CommandType.Text
cmd.Connection = conexionstock
sql = "INSERT INTO STOCK (ID,PRODUCTO,CANTIDAD,PRECIOSINIVA,PRECIOFINAL,IVA,PRECIOCONIVA,MARCA,PROVEEDOR,IMAGEN) "
sql += "VALUES (@ID,@PRODUCTO,@CANTIDAD,@PRECIOSINIVA,@PRECIOFINAL,@IVA,@PRECIOCONIVA,@MARCA,@PROVEEDOR,@IMAGEN)"
cmd.CommandText = sql
With cmd
.Parameters.Add("@ID", OleDb.OleDbType.VarChar).Value = TextBox9.Text
.Parameters.Add("@PRODUCTO", OleDb.OleDbType.VarChar).Value = TextBox1.Text
.Parameters.Add("@CANTIDAD", OleDb.OleDbType.VarChar).Value = TextBox2.Text
.Parameters.Add("@PRECIOSINIVA", OleDb.OleDbType.VarChar).Value = TextBox3.Text
.Parameters.Add("@PRECIOFINAL", OleDb.OleDbType.VarChar).Value = TextBox5.Text
.Parameters.Add("@IVA", OleDb.OleDbType.VarChar).Value = TextBox4.Text
.Parameters.Add("@PRECIOCONIVA", OleDb.OleDbType.VarChar).Value = TextBox8.Text
.Parameters.Add("@MARCA", OleDb.OleDbType.VarChar).Value = TextBox6.Text
.Parameters.Add("@PROVEEDOR", OleDb.OleDbType.VarChar).Value = TextBox7.Text
.Parameters.Add("@IMAGEN", OleDb.OleDbType.VarBinary).Value = ms.GetBuffer
End With
Try
cmd.ExecuteNonQuery() '
MsgBox("REGISTRO GUARDADO", MsgBoxStyle.Information, "Ingreso Correcto")
Catch ex As Exception
MsgBox(ex.ToString)
If ex.ToString.Contains("VALORES DUPLICADOS") Then
MsgBox("EL REGISTRO YA EXISTE")
Else
MsgBox(ex.ToString)
End If
End Try
Me.TextBox1.Text = ""
Me.TextBox9.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox5.Text = ""
Me.TextBox8.Text = ""
Me.TextBox4.Text = ""
Me.TextBox6.Text = ""
Me.TextBox7.Text = ""
Me.PictureBox1.Image = Nothing
Valora esta pregunta


0