Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
Try
Using conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Datos.accdb;")
conn.Open()
Dim command As New OleDbCommand("insert into Empleados([cedula], [tipo_documento], [nombre],[cargo],[genero],[fecha_nac],[ciudad],[direccion],[telefono], [movil] ,[usuario],[password],[email],[Picfoto]) values (@cedula, @tipo_documento, @nombre,@cargo,@genero,fecha_nac,@ciudad,@direccion,@telefono,@movil,@usuario,@password,@email, @foto)", conn)
With command.Parameters
.AddWithValue("@cedula", txtdni.Text)
.AddWithValue("@tipo_documento", Cbotipo.Text)
.AddWithValue("@nombre", txtNombre.Text)
.AddWithValue("@cargo", txtcargo.Text)
.AddWithValue("@genero", Cbosexo.Text)
.AddWithValue("@fecha_nac", dtFecha.Value)
.AddWithValue("@ciudad", txtciudad.Text)
.AddWithValue("@direccion", txtDireccion.Text)
.AddWithValue("@telefono", txtTelefono.Text)
.AddWithValue("@movil", txtmovil.Text)
.AddWithValue("@usuario", txtusuario.Text)
.AddWithValue("@password", txtpassword.Text)
.AddWithValue("@email", txtEmail.Text)
Try
Dim ms As New System.IO.MemoryStream
Dim bmpImage As New Bitmap(PicFoto.Image)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
bytImage = ms.ToArray()
ms.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
.AddWithValue("@foto", bytImage)
End With
command.ExecuteNonQuery()
MessageBox.Show("New account was successfuly added!", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information)
command.Dispose()
conn.Close()
PicFoto.Image = My.Resources.file
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "ERROR12", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub