UNIT 5 Data Binding and Deployment

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Data Binding and Deployment

1
2
 Data Binding
Is a process through which we can bind the GUI controls like
Textbox or List Box with data source like Data sets, array
 Data from database can be displayed in these controls.
 There are 2 types of data binding
1. Simple Data Binding
2. Complex Data Binding

3
1.Simple Data Binding
 Controls like Textbox or labels are bind with specific value of
data field.
 Controls used in this binding can display a single value at a
time.
2.Complex Data Binding
 Controls like list box ,Combo Box or Data Grid are bind with
multiple values of data field.
 Controls used in this binding can display a multiple values at a
time.

4
5
1.Simple Data Binding using Textbox
1.First add our database in the project by using server Explorer.
2.Drag and Drop the Textbox control on the form.
3.Set the Data Binding Text property of Textbox as follow:
i. Choose data source option.
ii. Choose your data connection
iii. choose Database object , then click on finish
iv. Select the fields which we want to display in the textbox.

6
2.Simple Data Binding using CheckBox
1.First add our database in the project by using server Explorer.
2.Drag and Drop the CheckBox control on the form.
3.Set the Data Binding Text property of CheckBox as follow:
i. Choose data source option.
ii. Choose your data connection
iii. choose Database object , then click on finish
iv. From property Window select Data Binding Text .
v. Select the fields which we want to display in the CheckBox.

17
3.Simple Data Binding using Label
1.First add our database in the project by using server Explorer.
2.Drag and Drop the Label control on the form.
3.Set the Data Binding Text property of Label as follow:
i. Choose data source option.
ii. Choose your data connection
iii. choose Database object , then click on finish
iv. From property Window select Data Binding Text .
v. Select the fields which we want to display in the Label.

18
19
1.Complex Data Binding using List Box/Combo Box(coding)
1.First add our database in the project by using server Explorer.
2. Drag and Drop the List Box/Combo Box control on the form.
3. Create connection object.
4. Create objects of dataset ,data adapter and command.
5. Set Combo Box/List Box data source and Display Member
property in coding

20
21
Navigating Means traversing the records from database.
Steps:
1. add Data sources.
2. Select Database & click next.
3. Select new connection.
4. Set data source & database file name then click ok.
5. Select table option &click finish.
6. Data source is added.
7. To see data source select data Menu which shows data sources.
8. Now drag drop required fields on the form.
9. Run the program.

22
Imports System.Data.OleDb
Public Class Form1
Dim cn As OleDbConnection
Dim ds As New DataSet
Dim cmd As OleDbCommand
Dim adpt As OleDbDataAdapter
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Nibe Sir\OneDrive\Desktop\stud.mdb")
cn.Open()
cmd = New OleDbCommand("select * from stud", cn)
adpt = New OleDbDataAdapter(cmd)
adpt.Fill(ds, "stud")
TextBox1.DataBindings.Add("text", ds, "stud.rollno")
TextBox2.DataBindings.Add("text", ds, "stud.name")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.BindingContext(ds, "stud").Position = 0
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.BindingContext(ds, "stud").Position = Me.BindingContext(ds, "stud").Position + 1
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Me.BindingContext(ds, "stud").Position = Me.BindingContext(ds, "stud").Position - 1
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Me.BindingContext(ds, "stud").Position = Me.BindingContext(ds, "stud").Count - 1
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
End
26
Deployment
is a process of installing application at client side.
i.e. setting up executable file on system.
 Use ‘Publish’ option from (Build) to create setup(.exe) file of an
application.

27

You might also like