Hi, I am trying to do some data checking before commiting the data back to the database. I have a datagrid in this data grid i have textboxes. The user can edit what they like. The first row in the datagrid is a phantom row. This is so users can add a row into the grid. I have then used VB.NET to manually get the data from the grid into a datatable. What i need to do is check that the Start date of a record is after the end date of the previouse record. I thought this would be simple but i dosen't see to work.
The code:
I first order the datatable by the date
datatable.defau ltview.sort = "Startdate DESC, EndDate DESC"
Then I use a loop to check it out
Dim rowcount as integer, _
nextrow as integer,
bDayGreaterThan 1 as boolean
For rowcount 0 to datatable.rows. count - 1
nextrow = rowcount + 1
If not is dbnull(startdat e) then
IF DateDiff(day, datatable.rows( rowcount).item( "StartDate" ), datatable.rows (nextrow).item( "EndDate")) then
bDayGreaterThan 1 = True
End if
End if
Next
How ever this does not work, it sorts the datatable out ok but in the loop it doesn't start from the top. It seems to start from 0 which could be anywhere in the datatable any one have any clues
Thanks
The code:
I first order the datatable by the date
datatable.defau ltview.sort = "Startdate DESC, EndDate DESC"
Then I use a loop to check it out
Dim rowcount as integer, _
nextrow as integer,
bDayGreaterThan 1 as boolean
For rowcount 0 to datatable.rows. count - 1
nextrow = rowcount + 1
If not is dbnull(startdat e) then
IF DateDiff(day, datatable.rows( rowcount).item( "StartDate" ), datatable.rows (nextrow).item( "EndDate")) then
bDayGreaterThan 1 = True
End if
End if
Next
How ever this does not work, it sorts the datatable out ok but in the loop it doesn't start from the top. It seems to start from 0 which could be anywhere in the datatable any one have any clues
Thanks
Comment