Custom Calender RRS feed

  • Question

  • User-829096311 posted


    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)
                While rdr.Read()
                    If CDate(rdr("thedate")) = date2 Then
                        output += rdr("thedate") & " " & rdr("event") & "<br>"
                        output += date2 & "<br>"
                    End If
                End While
            lblOutput.Text = output

    But every date is repeated by the number of events

    Saturday, September 8, 2018 9:02 PM

All replies

  • User409696431 posted

    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 <g class="gr_ gr_164 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="164" data-gr-id="164">on</g> the first event.  (Assuming your select fetches events ordered by date.)

    Sunday, September 9, 2018 1:23 AM
  • User-829096311 posted

    Thanks for reply
    The error is in the ELSE statement
    and I will fix it

    Monday, September 10, 2018 11:15 PM