0

I have an sql server table that I pass to a datatable, I obtain something like this:

ID      WHAT    START                   END
120548  TODO1   2017-03-27 00:00:00.000 2017-03-27 00:30:00.000
120549  TODO2   2017-03-27 00:00:00.000 2017-03-27 00:30:00.000
120463  TODO3   2017-03-27 14:00:00.000 2017-03-27 15:00:00.000
120557  TODO4   2017-03-27 09:30:00.000 2017-03-28 12:30:00.000

Notice Todo1 and Todo2, they have the same start and end time. I want to increment Todo2 and every possible next event (only if the start and end time are 00:00 - 00:30) of half an hour, so I did this function:

Dim dt As New DataTable()

            Dim oraInizio As DateTime
            Dim oraFine As DateTime
            Dim minuti As Integer = 0
            For Each row In dt.Rows
                oraInizio = row("eventstart")
                oraFine = row("eventend")

                If Convert.ToDateTime(row("eventstart")).Hour = "00" And Convert.ToDateTime(row("eventstart")).Minute = "00" Then
                    oraInizio = oraInizio.AddMinutes(minuti)
                    oraFine = oraFine.AddMinutes(minuti)
                    row("eventstart") = oraInizio
                    row("eventend") = oraFine
                    minuti = minuti + 30
                End If

            Next
            da.Fill(dt)

So this is the result I wish:

ID      WHAT    START                   END
120548  TODO1   2017-03-27 00:00:00.000 2017-03-27 00:30:00.000
120549  TODO2   2017-03-27 00:30:00.000 2017-03-27 01:00:00.000
120463  TODO3   2017-03-27 14:00:00.000 2017-03-27 15:00:00.000
120557  TODO4   2017-03-27 09:30:00.000 2017-03-28 12:30:00.000

Note if there were another Event, like Todo5 at 00:00-00:30 it should become 01:00-01:30. The function doesn't work, and in VS2015 I get the "cannot set the breakpoint error," so I ask you what I did wrong in it. Thank you.

tRuEsAtM
  • 3,517
  • 6
  • 43
  • 83
  • You need to be able to debug your code with breakpoints, look here to solve this problem, then you can properly find out the answer to your real problem. http://stackoverflow.com/questions/31644074/upgrade-to-visual-sudio-2015-and-now-cant-hit-break-points-in-debuging – Seano666 Apr 03 '17 at 16:49
  • What are the results you are getting now? Something does seem off in your code. – codeMonger123 Apr 03 '17 at 17:30
  • @codeMonger123 Right now I get all event at 00:00-00:030 I could think of some issue with the IF condition. Maybe I can't do it against "00" when datatimes are involved? – Gabriele Cozzolino Apr 04 '17 at 06:23
  • Sorry guys, I didn't realize that I was fillin' in the dt AFTER the loop, so I just moved the da.Fill(dt) part before the For and now it works as expected. – Gabriele Cozzolino Apr 04 '17 at 06:34

1 Answers1

0

Sorry guys, I didn't realize that I was fillin' in the dt AFTER the loop, so I just moved the da.Fill(dt) part before the For and now it works as expected.