Solved

How i can find DataSet Row #

Posted on 2004-08-09
8
150 Views
Last Modified: 2010-04-23
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
'------------------------------------------------------------------
        Try
            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
            xerr.ErrorsWritesIntoTextFile(ex.ToString)
            Console.WriteLine(ex.ToString)
            Return xlresult
        End Try
'------------------------------------------------------------------
instead of returing a particual value is it possible to send row # back
thanx
0
Comment
Question by:meharmahmood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
8 Comments
 
LVL 25

Accepted Solution

by:
RonaldBiemans earned 125 total points
ID: 11760134
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
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 11760145
if you then want the information of that row just do

       msgbox(xdsglacc.Tables(0).Rows(x).Item("accgltype"))

0
 
LVL 8

Assisted Solution

by:gregasm
gregasm earned 125 total points
ID: 11765639
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.

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10332854.html
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 8

Expert Comment

by:gregasm
ID: 11765659
0
 
LVL 8

Expert Comment

by:gregasm
ID: 11765662
0
 
LVL 8

Expert Comment

by:gregasm
ID: 11765795
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.
    myDataTable.Columns.Add(myDataColumn)
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question