Dear all
I try and finally come up with the solutions.
The code is as under:-
Imports MySql.Data.MySqlClient
Public Class Form1
Dim con As MySqlConnection = New MySqlConnection("data source=localhost;database=students;user id=root;password=root")
Dim ds As DataSet = New DataSet
Dim dataadapter As New MySqlDataAdapter("select * from users", con)
Dim cmd As MySqlCommand = New MySqlCommand()
Dim dv As DataView
Dim cm As CurrencyManager
Dim datareader As MySqlDataReader
Public Sub filldatasetandview()
ds = New DataSet
dataadapter.Fill(ds, "users")
dv = New DataView(ds.Tables("users"))
cm = CType(Me.BindingContext(dv), CurrencyManager)
End Sub
Public Sub bindfields()
TextBox1.DataBindings.Clear()
TextBox2.DataBindings.Clear()
TextBox3.DataBindings.Clear()
TextBox1.DataBindings.Add("text", dv, "userid")
TextBox2.DataBindings.Add("text", dv, "username")
TextBox3.DataBindings.Add("text", dv, "age")
End Sub
Public Sub showposition()
TextBox4.Text = cm.Position + 1 & " " & "of" & " " & cm.Count()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
filldatasetandview()
bindfields()
showposition()
End Sub
Private Sub previousrecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles previousrecord.Click
cm.Position = cm.Position - 1
showposition()
End Sub
Private Sub nextrecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nextrecord.Click
cm.Position = cm.Position + 1
showposition()
End Sub
Private Sub lastrecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lastrecord.Click
cm.Position = cm.Count - 1
showposition()
End Sub
Private Sub firstrecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles firstrecord.Click
cm.Position = 0
showposition()
End Sub
End Class