Dim resp As Boolean
resp = comprobarCampos()
If resp = True Then
REM meto consulta numalum
Dim oDataadapter As New SqlDataAdapter
' Dim oComando As New SqlCommand(sSQL, CONN)
Dim iResultado As Integer
Dim oComando As New SqlCommand("INSERT INTO Frutas (idCursoFruta,idAlumnoFruta,fecha,nFrutas) VALUES(@idCursoFruta,@idAlumnoFruta,@fecha,@nFrutas)", CONN)
oDataadapter.InsertCommand = oComando
oDataadapter.InsertCommand.Parameters.Add(New SqlParameter("@idCursoFruta", SqlDbType.Int))
oDataadapter.InsertCommand.Parameters.Add(New SqlParameter("@idAlumnoFruta", SqlDbType.Int))
oDataadapter.InsertCommand.Parameters.Add(New SqlParameter("@fecha", SqlDbType.DateTime))
oDataadapter.InsertCommand.Parameters.Add(New SqlParameter("@nFrutas", SqlDbType.Bit))
oDataadapter.InsertCommand.Parameters("@idCursoFruta").Value = LTrim(RTrim(Val(Microsoft.VisualBasic.Left(cbbCurso.Text, 2))))
oDataadapter.InsertCommand.Parameters("@idAlumnoFruta").Value = LTrim(RTrim(Val(Microsoft.VisualBasic.Left(cbbNumAlum.Text, 2))))
Esta es la linea------->oDataadapter.InsertCommand.Parameters("@fecha").Value = CDate(Format$(dtpFecha.Value.Date, "yyyy-MM-dd"))
oDataadapter.InsertCommand.Parameters("@nFrutas").Value = chkFruta.CheckState
CONN.Open()
' ejecutar comando de inserción del adaptador
iResultado = oDataadapter.InsertCommand.ExecuteNonQuery()
' cerrar conexión
CONN.Close()
MsgBox("Se añadio el registro con exito", MsgBoxStyle.OkOnly)
botones(2)
carganumAlum()
Else
MsgBox("Algun dato introducido es incorrecto", MsgBoxStyle.OkOnly)
End If