hola a todos tengo una aplicacion hecha en windows donde tengo un formulario de registro de empleados el problema que tengo es que cuando voy a guardar los datos a la tabla no los guardas, pasa que cuando yo le ingreso los datos le doy guardar y me sale un mensaje esta seguro que desea guardar los datos le doy que si y me sale otro mensaje que dice los datos hancido almacenados y las cajas de texto aparecen vacias como si se hubieran hido los datos a la tabla pero cuando voy y abro la tabla empleados los datos no aparecen guardados les pido les ruego que me hagan el favor y me ayuden se los agrdeceria el alma aqui les mando mi codigo para que lo corrigan o me digan que le falta gracias por su ayuda y que Dios los bendiga
Private Sub Guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Guardar.Click
If txtid.Text = "" Then
MsgBox(
"debe digitar una identificacion")
txtid.Focus()
Exit Sub
Else
If Cbosecc.Text <> "" Then
Dim adap As SqlDataAdapter
Dim da As New DataSet
conectar()
adap =
New SqlDataAdapter("Select IdCentroCosto from CentroCosto where NombreCentroCosto=" & "'" & Cbosecc.Text & "'", con)
adap.Fill(da,
"manu")
Label14.Text = da.Tables(
"manu").Rows(0).Item("IdCentroCosto")
Dim command As SqlCommand
command =
New SqlCommand
command.Connection = con
command.CommandText =
"insert into Empleados (Identificacion,NombreEmpleado,PrimerApellido,SegundoApellido,Direccion,Telefono,Celular,Sexo,Cargo,Estado,Email,IdCentroCosto)values(" & "'" & txtid.Text & "'" & "," & "'" & txtnom.Text & "'" & "," & "'" & txtpa.Text & "'" & "," & "'" & txtsa.Text & "'" & "," & "'" & txtdir.Text & "'" & "," & "'" & txttel.Text & "'" & "," & "'" & txtcel.Text & "'" & "," & "'" & Cbosex.Text & "'" & "," & "'" & Cbocar.Text & "'" & "," & "'" & Cboest.Text & "'" & "," & "'" & txtimail.Text & "'" & "," & "'" & Label14.Text & "'" & ")"
command.ExecuteNonQuery()
command.Connection.Close()
If command.Connection.State = ConnectionState.Closed Then
MessageBox.Show(
" los datos hancido almacenados ")
txtid.Enabled =
True
txtnom.Enabled =
True
txtpa.Enabled =
True
txtsa.Enabled =
True
txtdir.Enabled =
True
txttel.Enabled =
True
txtcel.Enabled =
True
txtimail.Enabled =
True
Cbosex.Enabled =
True
Cbocar.Enabled =
True
Cboest.Enabled =
True
Cbosecc.Enabled =
True
Buscar.Enabled =
False
End If
'habilitar controles
txtid.Enabled =
False
txtnom.Enabled =
False
txtpa.Enabled =
False
txtsa.Enabled =
False
txtdir.Enabled =
False
txttel.Enabled =
False
txtcel.Enabled =
False
txtimail.Enabled =
False
Cbosex.Enabled =
False
Cbocar.Enabled =
False
Cboest.Enabled =
False
Cbosecc.Enabled =
False
'habilitar Botones
Ingresar.Enabled =
True
Guardar.Enabled =
True
Modificar.Enabled =
True
Actualizar.Enabled =
True
Buscar.Enabled =
True
Eliminar.Enabled =
False
Cancelar.Enabled =
True
'limpiar controles
txtid.Text =
" "
txtnom.Text =
" "
txtpa.Text =
" "
txtsa.Text =
" "
txtdir.Text =
" "
txttel.Text =
" "
Cbosex.Text =
""
Cboest.Text =
""
Cbosecc.Text =
""
Cbocar.Text =
""
txtcel.Text =
""
txtimail.Text =
" "
txtid.Focus()
Else
MsgBox(
"debe escoger una opcion")
Cbosecc.Focus()
End If
End If
End Sub