Binding Manager Base

Posted by 001Imahaveer under VB.NET on 12/18/2012 | Points: 10 | Views : 4423 | Status : [Member] | Replies : 0
Imports System.Data.SqlClient
Imports System.Data

Public Class Form1

Dim bm As BindingManagerBase
Dim ds As DataSet
Dim adp As OleDb.OleDbDataAdapter


Sub showrecord(ByVal pos As Integer)
TextBox1.Text = ds.Tables(0).Rows(pos)("c_id")
TextBox2.Text = ds.Tables(0).Rows(pos)("c_name")
TextBox3.Text = ds.Tables(0).Rows(pos)("c_address")
TextBox4.Text = ds.Tables(0).Rows(pos)("c_phone")
TextBox5.Text = ds.Tables(0).Rows(pos)("c_email")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ds = New DataSet
Dim dt As New DataTable
Dim con As New OleDb.OleDbConnection("provider=sqloledb; server=MICROSOF-FDE61F\SQLEXPRESS; database=Hotel; userid=; password=; Trusted_connection=yes")
con.Open()
adp = New OleDb.OleDbDataAdapter("select*from Booking", con)
adp.Fill(ds, "Booking")
bm = Me.BindingContext(ds, "Booking")
bm.Position = 0
showrecord(bm.Position)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
bm.Position -= 1
showrecord(bm.Position)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
bm.Position += 1
showrecord(bm.Position)

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
bm.Position = 0
showrecord(bm.Position)
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
bm.Position = bm.Count - 1
showrecord(bm.Position)
End Sub


End Class

I have 5 text boxes and five buttons in my code. i used binding manager base to bind data. This code binds data from starting. i want that if i enter any id from middle of sql database in textbox1 and click on Load button it should load data from there. it should also bind data from there. like if i enter from 5th id it should bind data from 5th id. how can i do that.




Responses

(No response found.)

Login to post response