imagen en mysql y vb.net
Publicado por bryan (8 intervenciones) el 17/01/2016 07:33:12
muy buenas con todos disculpen pero me pueden ayudar
eh estado aprendiendo bastante sobre vb
pero se que me falta mucho y quisiera que me explicaran como poder guardar imagenes en vb.net estoy haciendo un pequeño programa y pero no se como guargar una imagen en una base de datos me podrias ayudar este es mi codigo podrian darme una ayudita por fix o explicarme :'(
'este codigo pertenece al boton de guardar
eh estado aprendiendo bastante sobre vb
pero se que me falta mucho y quisiera que me explicaran como poder guardar imagenes en vb.net estoy haciendo un pequeño programa y pero no se como guargar una imagen en una base de datos me podrias ayudar este es mi codigo podrian darme una ayudita por fix o explicarme :'(
'este codigo pertenece al boton de guardar
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Public Class Personal
Dim conexioN As New Class_personal
Dim datos As New Class_dat_personal
Private Sub Guardar_Click(sender As Object, e As EventArgs) Handles Nuevo.Click
datos.Cod_Personl = bcodigo.Text
datos.nombr = Bnombre.Text
datos.apelli = Bapellido.Text
If Nuevo.Text.ToLower = "nuevo" Then
Nuevo.Text = "Guardar"
habilitar_Click()
Else
Nuevo.Text = "Nuevo"
Try
If conexioN.ingresar_dtos_personal_(datos) Then
MessageBox.Show("los datos han sido guardados", "guardado", MessageBoxButtons.OK, MessageBoxIcon.Information)
limpiar()
desabilitar_Click()
End If
Catch ex As MySqlException
MessageBox.Show("los datos NO se han guardado", "guardar", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
cerrar()
End Try
End If
end sub
end class
Public Class Class_personal
Private adaptador As New MySqlDataAdapter
Public Function ingresar_dtos_personal_(ByVal datos As Class_dat_personal) As Boolean
Dim estado As Boolean = True
Try
conex_Global()
adaptador.InsertCommand = New MySqlCommand("Insert into personal (CI,Nombre,Apellido,Direccion,Sexo,Razon_social,Celular,Convencional) values(@CI,@Nombre,@Apellido,@Direccion,@Sexo,@Razon_social,@Celular,@Convencional)", conexion)
adaptador.InsertCommand.Parameters.Add("@CI", MySqlDbType.VarChar, 11).Value = datos.Cod_Personl
adaptador.InsertCommand.Parameters.Add("@Nombre", MySqlDbType.VarChar, 45).Value = datos.nombr
adaptador.InsertCommand.Parameters.Add("@Apellido", MySqlDbType.VarChar, 45).Value = datos.apelli
adaptador.InsertCommand.Parameters.Add("@Direccion", MySqlDbType.VarChar, 45).Value = datos.dreccion
adaptador.InsertCommand.Parameters.Add("@Sexo", MySqlDbType.VarChar, 2).Value = datos.sex
adaptador.InsertCommand.Parameters.Add("@Razon_social", MySqlDbType.VarChar, 45).Value = datos.razon_soc
adaptador.InsertCommand.Parameters.Add("@Celular", MySqlDbType.VarChar, 10).Value = datos.celu
adaptador.InsertCommand.Parameters.Add("@Convencional", MySqlDbType.VarChar, 7).Value = datos.conve
adaptador.InsertCommand.Parameters.Add("@picture", MySqlDbType.LongBlob).Value = datos.picture
conexion.Open()
adaptador.InsertCommand.Connection = conexion
adaptador.InsertCommand.ExecuteNonQuery()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
estado = False
Finally
cerrar()
End Try
Return estado
End Function
end class
Public Class Class_dat_personal
Private cod_personal As String
Private Nombre As String
Private apellido As String
Private celuar As String
Private convenci As String
Private razon_social As String
Private direccion As String
Private sexo As String
Private pictur As Byte
Public Property picture As Byte
Get
Return pictur
End Get
Set(value As Byte)
pictur = value
End Set
End Property
end class
Valora esta pregunta


0