C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ADO.NET »

BindingManagerBase


Posted Date: 07 Nov 2009    Resource Type: Code Snippets    Category: ADO.NET
Author: krishnavenikaladiMember Level: Gold    
Rating: 1 out of 5Points: 4



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














Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Bindingmanagerbase  .  Bindingcontext  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Sqlexceptionclasses
Previous Resource: Intranet Search
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use