Solved

How i can find DataSet Row #

Posted on 2004-08-09
8
146 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 8

Expert Comment

by:gregasm
Comment Utility
0
 
LVL 8

Expert Comment

by:gregasm
Comment Utility
0
 
LVL 8

Expert Comment

by:gregasm
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

15 Experts available now in Live!

Get 1:1 Help Now