como hago para que me guarde en una base de datos o en una tabla la fecha actual utilizando un datatimepicker,necesito de su valiosa ayuda urgente o si no no podre presentar el proyecto y estoy cogido de tiempo, espero y me ayuden con eso se los agradeceria en el alma, les pido el favor y me ayuden gracias. este el codigo que tengo en el boton guardar
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 <> "" And Cbomot.Text <> "" Then
Dim command As SqlCommand
command =
New SqlCommand
command.Connection = con
command.CommandText =
"insert into Motivo_Ausencia (Identificacion,NombreCausa,FechaCausa,HoraCausa,Observaciones)values(" & "'" & Trim(txtid.Text) & "'" & "," & "'" & Cbomot.Text & "'" & "," & DateTimePickerFormat.Time & "," & "'" & Trim(txth.Text) & "'" & "," & "'" & Trim(txtobs.Text) & "'" & ")"
command.ExecuteNonQuery()
command.Connection.Close()
If command.Connection.State = ConnectionState.Closed Then
MessageBox.Show(
"ausencia registrada")
txtid.Enabled =
True
txtnom.Enabled =
True
txtap.Enabled =
True
txtsa.Enabled =
True
Cbomot.Enabled =
True
Dtpmes.Enabled =
True
txth.Enabled =
True
txtobs.Enabled =
True
Buscar.Enabled =
False
End If
'habilitar controles
txtid.Enabled =
False
txtnom.Enabled =
False
txtap.Enabled =
False
txtsa.Enabled =
False
Cbosecc.Enabled =
False
Cbomot.Enabled =
False
Dtpmes.Enabled =
False
txth.Enabled =
False
txtobs.Enabled =
False
'habilitar botones
Ingresar.Enabled =
True
Guardar.Enabled =
True
Modificar.Enabled =
False
Actualizar.Enabled =
False
Buscar.Enabled =
True
Eliminar.Enabled =
False
Cancelar.Enabled =
True
'limpiar controles
txtid.Text =
" "
txtnom.Text =
" "
txtap.Text =
""
txtsa.Text =
" "
Cbosecc.Text =
" "
Cbomot.Text =
" "
txth.Text =
" "
txtobs.Text =
""
txtid.Focus()
End If
End If
End Sub