Solved

Find the index of a row from a datatable

Posted on 2010-08-31
2
501 Views
Last Modified: 2013-12-25

I need to be able to find the index of a particular row.  I have the follwoing code:

    Private Sub frmPermitEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        StatusBarNavInfo = "Displaying 1 of " & RecordCount & " permits found"
        StatusBar.Items(0).Text = StatusBarNavInfo

        SQLConn = New SqlConnection(SQLConnString)
        SQLConn.Open()
        SQLAdapter = New SqlDataAdapter(strSQL, SQLConn)
        dTable = New DataTable
        SQLAdapter.Fill(dTable)

        DR = dTable.Rows(0)
        TotalRowCount = DR.Table.Rows.Count
        LoadControlData()

    End Sub

Open in new window


How can I find the index of a datarow.  I want to allow my users to navigate, similar to a datacontrol with bound controls.  
0
Comment
Question by:DRRobinson
[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
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 33565218
Based on what information do you want the index ? What do  you want to do with it ?

If you search through the primary key:
http://msdn.microsoft.com/en-us/library/ydd48eyk.aspx
http://support.microsoft.com/kb/305561
0
 

Author Comment

by:DRRobinson
ID: 33565288
Well, I figured out a method to accomplilsh my goal.  As soon as the for loads that displays the data from the first row, I set a Module level variable to 0.   Then when a next or previous button is pressed, I just increment and decrement the currently displayed row index.  Then set that new index to the module level variable.  works great.  Thanks for the quick response!
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

696 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