Binding manager base is a class which is used to access data from database and to perform navigations of data .The database connection to be used is disconnected.
Step 1: Design windows forms application (vb.net).
Controls: LABEL1?TEXT (PROPERTY) -?EMPLOYEENUMBER LABEL2?TEXT (PROPERTY)?EMPLOYEENAME TEXTBOX1?ENABLE (PROPERTY) ?FALSE TEXTBOX2-?ENABLE (PROPERTY) ?FALSE BUTTON1?TEXT?FIRST BUTTON2?TEXT?NEXT BUTTON3?TEXT?PREVIOUS BUTTON4?TEXT?LAST
Step2:
Namespaces to be used Imports System.Data Imports System.Data.OracleClient
Public Class Form1 //defining connection object,adapter object,dataset, Dim cn As OracleConnection Dim da As OracleDataAdapter Dim ds As DataSet //defining variable of binding manager base Dim bmb As BindingManagerBase //method to get data from database Public Sub showemp(ByVal pos As Integer) TextBox1.Text = ds.Tables(0).Rows(pos)("empno") TextBox2.Text = ds.Tables(0).Rows(pos)("ename")
End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
//establishing the connection and filling data base table cn = New OracleConnection("user id=scott;password=tiger;data source=ganesh1")
da = New OracleDataAdapter("select * from emp", cn) ds = New DataSet() da.Fill(ds, "temp") //using binding context binding the variable with datamemeber bmb = BindingContext(ds.Tables(0)) //points to the first datamember bmb.Position = 0 //calling of method showemp(bmb.Position)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click bmb.Position = 0 showemp(bmb.Position) End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click bmb.Position = bmb.Position + 1 showemp(bmb.Position) End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click bmb.Position = bmb.Position - 1 showemp(bmb.Position) End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click bmb.Position = bmb.Count - 1 showemp(bmb.Position) End Sub End Class
Step3 Execute the form
Explanation: ?The above code establishes the connection with database using disconnected model of connection. ?Using binding context bind the database member with the binding manager base variable. ?Using bmb.position we can able to navigate the data rows of data member
|
No responses found. Be the first to respond and make money from revenue sharing program.
|