Solved

Find the index of a row from a datatable

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

831 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