This is my getDate function:
Private Function GetCalendarData(ByVal start As Date, ByVal [end] As Date) As DataTable
Dim rfTecnico As Integer = Session("idUtente")
Dim da As New SqlDataAdapter("statoric.id, clienti.RagSociale, ISNULL(CAST(statoRic.DataAss AS DATE) + CONVERT(datetime, CONVERT(varchar(10), statoRic.OraDalle / 100)+ ':' + CONVERT(varchar(10), statoRic.OraDalle % 100)) as eventstart, ISNULL(CAST(statoRic.DataAss AS DATE) + CONVERT(datetime, CONVERT(varchar(10), statoRic.OraAlle / 100)+ ':' + CONVERT(varchar(10), statoRic.OraAlle % 100)),0) as eventend
From StatoRic
INNER Join
(Richieste INNER JOIN Clienti
On clienti.IDCliente=Richieste.RFCliente)
On StatoRic.RFRic=Richieste.IDRic
WHERE(RFStato = 11 or RFStato = 12 Or rfstato = 13) And Attuale=1 and NOT (([eventend] <= @start) OR ([eventstart] >= @end)) And RFTecnico=" & rfTecnico, ConfigurationManager.ConnectionStrings("daypilot").ConnectionString)
da.SelectCommand.Parameters.AddWithValue("start", start)
da.SelectCommand.Parameters.AddWithValue("end", [end])
Dim dt As New DataTable()
da.Fill(dt)
Return dt
End Function
statoric.dataass and oradalle and oraalle can be null
I get a null reference exception.
Furthermore when I debug the function I see that start date and end has odd values (like 25-02-3898 and such)
I call the function with this:
DayPilotCalendarWeek.DataSource = GetCalendarData(DayPilotCalendarWeek.StartDate, DayPilotCalendarWeek.EndDate.AddDays(1))