Solved

How i can find DataSet Row #

Posted on 2004-08-09
8
151 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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 …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

623 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