Código:
me marca este errorPublic Function ultimoMes() Try Using cn = New SqlConnection(ConfigurationManager.ConnectionStrings("cn").ToString()) Dim cmd As SqlCommand = cn.CreateCommand cn.Open() cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add(New SqlParameter("@Contrato", txtnoContrato.Text)) cmd.CommandText = "ultimoMesqPago" Dim da As New SqlDataAdapter(cmd) Dim dt As New DataTable da.SelectCommand = cmd da.Fill(dt) Dim reader As SqlDataReader reader = cmd.ExecuteReader() If reader.Read() Then frmPdetalleRecibo.txtnoContrato.Text = reader.Item("noContrato") frmPdetalleRecibo.dtUltimaFPago.Value = New Date(reader.Item("YFinal"), reader.Item("MesFinal"), 1) 'Aqui marca error frmPdetalleRecibo.cbomes1.SelectedText = reader.Item("MesInicial") frmPdetalleRecibo.cboaño1.SelectedText = reader.Item("YInicial") frmPdetalleRecibo.cbomes2.SelectedText = reader.Item("MesFinal") frmPdetalleRecibo.cboaño2.SelectedText = reader.Item("YFinal") End If cn.Close() End Using Catch ex As Exception End Try End Function
La conversión del tipo 'DBNull' en el tipo 'Integer' no es válida.