I have a VB.net program, running a SQL Database. I have been struggling to save any amended fields successfully and easily. I stumbled onto a remedy, but I don’t know how to use Index = table.Rows.Count to navigate to First Record, Next Record and Previous Record, I only know how to use it to go to the Last Record. When I use the Last record, I can save the data without having to go out of the form and back in, it dynamically allows me to save.
Can someone please point me in the right direction.
My Code is
Private Sub BtnFirst_Click(sender As Object, e As EventArgs) Handles BtnFirst.Click
Dim Con As New SqlConnection("Connection String")
Con.Open()
Index = 0
Con.Close()
ShowData(Index)
End Sub
Private Sub BtnNext_Click(sender As Object, e As EventArgs) Handles BtnNext.Click
Dim Con As New SqlConnection("Connection String")
Con.Open()
Index += 1
Con.Close()
ShowData(Index)
End Sub
Private Sub BtnPrevious_Click(sender As Object, e As EventArgs) Handles BtnPrevious.Click
Dim Con As New SqlConnection("Connection Strige")
Con.Open()
Index -= 1
Con.Close()
ShowData(Index)
End Sub
Private Sub BtnLast_Click(sender As Object, e As EventArgs) Handles BtnLast.Click
Dim Con As New SqlConnection("Connection String")
Con.Open()
Index = table.Rows.Count - 1
Con.Close()
ShowData(Index)
End Sub
4