Solved

How i can find DataSet Row #

Posted on 2004-08-09
8
147 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

864 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now