How i can find DataSet Row #

I have dataset with a primery key.
I had find row with my primery key so i m able to get that row but how i can get that row # which i find.
cod is here
            Dim myDataRowCollection As DataRowCollection
            Dim foundRow As DataRow
            myDataRowCollection = xdsglacc.Tables(0).Rows
            Dim arrKeyVals(0) As Object
            arrKeyVals(0) = tcaccount
            If myDataRowCollection.Contains(arrKeyVals) Then
                foundRow = myDataRowCollection.Find(arrKeyVals)
                xlresult = LTrim(RTrim(foundRow.Item("accgltype")))
            End If
            Return xlresult
        Catch ex As Exception
            Return xlresult
        End Try
instead of returing a particual value is it possible to send row # back
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

RonaldBiemansConnect With a Mentor Commented:
if you want the row index do something like this

        Dim found As DataRow
        Dim dv As DataView
        dv = xdsglacc.Tables(0).DefaultView
        dv.Sort = "yourprimarykey"
        Dim x As Integer = dv.Find(tcaccount)

x will contain row number
if you then want the information of that row just do


gregasmConnect With a Mentor Commented:
You should add a calculated column to the table, and then when you retrieve the row, you can also find out the row number. This PAQ will help you on your way.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Here's sample code on how to create a calculated column. Add this column to yoru table, and then when you retrieve the row, check the row number which will be the value of this column.

myDataColumn = New DataColumn()
    myDataColumn.DataType= System.Type.GetType("System.Int32")
    myDataColumn.ColumnName = "RowNum"
    myDataColumn.AutoIncrement = True
    myDataColumn.Caption = "ID"
    myDataColumn.ReadOnly = True
    myDataColumn.Unique = True
    ' Add the column to the DataColumnCollection.
All Courses

From novice to tech pro — start learning today.