Last post Sep 10, 2018 11:15 PM by ThisIsYusuf
Sep 08, 2018 09:02 PM|ThisIsYusuf|LINK
I am use this code to create a calendar and bring the event from access database but i get a repeated values
Dim output As String = ""
Dim date1 As Date = #01/01/2018#
Dim days As Long = DateDiff(DateInterval.Day, date1, Now())
For i = 0 To days - 1
Dim date2 As Date = date1.AddDays(i)
Dim rdr As OleDbDataReader = DirectCast(AccessDataSource1.[Select](DataSourceSelectArguments.Empty), OleDbDataReader)
If CDate(rdr("thedate")) = date2 Then
output += rdr("thedate") & " " & rdr("event") & "<br>"
output += date2 & "<br>"
lblOutput.Text = output
But every date is repeated by the number of events
Sep 09, 2018 01:23 AM|KathyW|LINK
That is because you have coded it to do that.
If you want the date to show once, when there are multiple events on that day, you need to change your logic to only output the date on the first event. (Assuming your select fetches events ordered by date.)
Sep 10, 2018 11:15 PM|ThisIsYusuf|LINK
Thanks for reply
The error is in the ELSE statement
and I will fix it