Navigating Records Problem
Posted on 2005-03-24
anyone know why the code below does not work? i have 4 buttons on the form which have the following OnClick values
when i click on the "next" button if goes to the next record. if i click next again it does not go to the 3rd record. if i click on any of the other buttons it always ends up going back to the first record.
anyone know whats going on?
Dim m_cnADONetConnection As New SqlConnection
Dim m_daDataAdapter As New SqlDataAdapter
Dim m_dtContacts As New DataTable
Dim m_rowPosition As Integer
sub Page_Load(sender as Object, e as EventArgs)
m_cnADONetConnection.ConnectionString = "MyconnectionString"
m_daDataAdapter = New SqlDataAdapter("SELECT * FROM TABLE1",m_cnADONetConnection)
Private Sub ShowCurrentRecord()
If m_dtContacts.Rows.Count = 0 Then
testbox1.text = ""
testbox2.text = ""
testbox1.text = m_dtContacts.Rows(m_rowPosition)("reviewer").ToString()
testbox2.text = m_dtContacts.Rows(m_rowPosition)("date").ToString()
Sub ToFirstRecord(Source as Object, E as EventArgs)
m_rowPosition = 0
'if not at the first row, go back one row and show the record
Sub ToPreviousRecord(Source as Object, E as EventArgs)
If m_rowPosition <> 0 Then
m_rowPosition = m_rowPosition - 1
'if not on the last row, advance one row and show the record
Sub ToNextRecord(Source as Object, E as EventArgs)
If m_rowPosition <> (m_dtContacts.Rows.Count - 1) Then
m_rowPosition = m_rowPosition + 1
'if there are any rows in the data table, move to the last and show the record
Sub ToLastRecord(Source as Object, E as EventArgs)
If m_dtContacts.Rows.Count <> 0 then
m_rowPosition = m_dtContacts.Rows.Count - 1