L
Lorenzo
Hello There,
I have the following code that I need to optimize but I have somenthing that
doesn't work quite as expected:
I am doing the following: I am coloring a calendar according to dates
present in the DB yellow if the dates are present, blank for available
dates. I have some problems handling NULL values. The following code works
well as long I don't encounter a NULL value because it doesn't do what I'd
like it to do.
It should check each and every row returned and evaluate if the row has a
record, if it does it should then render a yellow background color for my
calendar. I have not included the code that make me select a value from a
DropDownList control and pass it to the query as a parameter. Whan I select
an apartment that contains NULL values it DOES NOT color yellow any other
previous date that were present in the DB for that particular apartment I
simply have everything white.
Why is that, I don't get it. I have this out of hands in the terms that
clearly exits my IF ... THEN statement at the first NULL value that it finds
without rendering the other dates. I hope this explains my situation.
Dim dr as OleDbDataReader
Dim strSQL as String = "SELECT dteDataArrivo, dteDataPartenza FROM
tblPrenotazioni WHERE IDImmobile = " & lstApt.SelectedValue
Dim cmd as New OleDbCommand(strSQL, objConnessione)
objConnessione.Open()
dr = cmd.ExecuteReader()
Do While dr.Read()
If Not IsDBNull(dr.Item(0)) and Not IsDbNull(dr.Item(1)) Then
If (E.Day.Date >= dr.Item(0)) and (E.Day.Date < dr.Item(1)) Then
e.cell.BackColor = System.Drawing.Color.Yellow
End If
Else
e.cell.BackColor = System.Drawing.Color.White
lblErrors.Text= "Empty Dates founds"
End If
Loop
objConnessione.Close()
Thanks for your help
L.
I have the following code that I need to optimize but I have somenthing that
doesn't work quite as expected:
I am doing the following: I am coloring a calendar according to dates
present in the DB yellow if the dates are present, blank for available
dates. I have some problems handling NULL values. The following code works
well as long I don't encounter a NULL value because it doesn't do what I'd
like it to do.
It should check each and every row returned and evaluate if the row has a
record, if it does it should then render a yellow background color for my
calendar. I have not included the code that make me select a value from a
DropDownList control and pass it to the query as a parameter. Whan I select
an apartment that contains NULL values it DOES NOT color yellow any other
previous date that were present in the DB for that particular apartment I
simply have everything white.
Why is that, I don't get it. I have this out of hands in the terms that
clearly exits my IF ... THEN statement at the first NULL value that it finds
without rendering the other dates. I hope this explains my situation.
Dim dr as OleDbDataReader
Dim strSQL as String = "SELECT dteDataArrivo, dteDataPartenza FROM
tblPrenotazioni WHERE IDImmobile = " & lstApt.SelectedValue
Dim cmd as New OleDbCommand(strSQL, objConnessione)
objConnessione.Open()
dr = cmd.ExecuteReader()
Do While dr.Read()
If Not IsDBNull(dr.Item(0)) and Not IsDbNull(dr.Item(1)) Then
If (E.Day.Date >= dr.Item(0)) and (E.Day.Date < dr.Item(1)) Then
e.cell.BackColor = System.Drawing.Color.Yellow
End If
Else
e.cell.BackColor = System.Drawing.Color.White
lblErrors.Text= "Empty Dates founds"
End If
Loop
objConnessione.Close()
Thanks for your help
L.