Yes, you can use order by ( marks ) clause to sort your students then select any by row index.
dataset.Tables("StudentRank").Rows (4).Item (2)
is okay if dataset is an identifier, (in that case, not a good choice to use a keyword as identifier)
you can use this code to get your row
Dim dt As New DataSet
Dim rankStudent As DataRow = dt.Tables("Student Rank").Rows(4)
if you are searching for a student for example with student name
Dim rankStudent As DataRow = dt.Tables("Student Rank").Rows(4)
For Each d As DataRow In dt.Tables("Student Rank").Rows
If String.Compare(d.Item(0), "studentname") = 0 Then
rankStudent =
Exit For
End If
Next
once you have your target record, you can do anything you want with it.
i prefer if your project has datatype (StudentRank) of your table, then use that as a type of row, that will allow you to access column names as properties of rankstudents
e.g
dim rankstudent as [projectname].[datasetname].[table name with word row]
addition to solution:
in your database query/ select, you can use following to add row number (as rank)
SELECT ROW_NUMBER()
OVER (ORDER BY StudentMarks desc) AS Rank,
StudentId as rollNO, StudentName, StudentMarks
FROM Students
output would be like:
rank rollno studentName StudentMarks
1 y jack [maximum marks]
2 x jill [less than maximum marks but more than everyone else]
now if you want to have someone jill's rank you will use
SELECT * FROM
(SELECT ROW_NUMBER()
OVER (ORDER BY StudentMarks desc) AS Rank,
StudentId as rollNO, StudentName, StudentMarks
FROM Students) AS std
WHERE StudentName='Jill'
output would be
rank rollno studentName StudentMarks
2 x jill [jill's Marks]