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.