Hey there.
Its Ruan

I have a little problem. I have a column Student number, and i can access all the individual student number values in the database ACCEPT one... the very last one in the column.

this is my code

String StudentNumber = myDS.Tables[0].Rows[myDs.rows.count]["Student_Nr"].ToString();

but when i do that , it says that there isnt a row there.

but then when i do this..

String StudentNumber = myDS.Tables[0].Rows[myDs.rows.count-1]["Student_Nr"].ToString();

it gives me the SECOND last row...
i have no idea why, it breaks the bounds of logic and its on the verge of breaking the bounds of Gravity...

Thank you =)


Why do you think that it is giving you the 2nd to last row? Are you viewing the data yourself and sure that it is the second to last row?

Generally speaking .Rows[index] is zero based. Therefore requesting an index that is equal to the number of rows would be out of bounds. So, Rows[count - 1] should return the last row, not the second to last.

Mister croker10

You are very much correct. i had a problem with the database Automatically re-ordering the data in it, so the last record i added, wasn't necessarily in the last position =)

So thank you for some of your wise words =)

This question has already been answered. Start a new discussion instead.