Solved

Find the index of a row from a datatable

Posted on 2010-08-31
2
472 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

25 Experts available now in Live!

Get 1:1 Help Now