Add, Delete, and Edit Records - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Add, Delete, and Edit Records

Description:

resides in local machine. 1. 2. Initial Procedures. Private Sub unlocktextboxes ... resides in local machine. 1. 2. Step 2: Update the Database. Step 2 ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 12
Provided by: fisherbu
Category:
Tags: add | delete | edit | records | resides

less

Transcript and Presenter's Notes

Title: Add, Delete, and Edit Records


1
Add, Delete, and Edit Records
  • Explain the two-step approach
  • The techniques for adding, deleting, and editing
    records

2
(No Transcript)
3
A Two-Step Process
  • Changes are first made to the dateset.
  • Database is then updated.

Project
database
dataset
Form1 Form2
invoice
customer
1
2
customer
invoice line item
part

resides in local machine
4
Initial Procedures
Private Sub Form1_Load() Handles MyBase.Load
locktextboxes() Adapter1.Fill(DataSe
t11) displayposition() End Sub
Private Sub unlocktextboxes()
TextBox1.ReadOnly False
TextBox2.ReadOnly False
TextBox3.ReadOnly False
TextBox4.ReadOnly False
TextBox5.ReadOnly False End Sub
Private Sub locktextboxes()
TextBox1.ReadOnly True
TextBox2.ReadOnly True
TextBox3.ReadOnly True
TextBox4.ReadOnly True
TextBox5.ReadOnly True End Sub
5
Step 1 make changes to the dataset
6
Adding a Record to the Dataset
Private Sub AddRecord_Click() Handles
AddRecord.Click generate a blank record
BindingContext(DataSet11, "vehicle").AddNew()
unlocktextboxes () End Sub
'save the newly added record to the dataset
Private Sub SaveRecord_Click() Handles
SaveRecord.Click 'this line is needed to
attach the newly added record to the dataset
BindingContext(DataSet11, "vehicle").EndCurren
tEdit() locktextboxes () End Sub
'discard the record being addded to the dataset
Private Sub DiscardAdd_Click() Handles
DiscardAdd.Click BindingContext(DataSet11
, "vehicle").CancelCurrentEdit()
locktextboxes () End Sub
7
Edit the Current Record
'edit the current record Private Sub
EditRecord_Click() Handles EditRecord.Click
unlocktextboxes() End Sub
'save the changes made to the current record to
the dataset Private Sub SaveEdit_Click()
Handles SaveEdit.Click
BindingContext(DataSet11, "vehicle").EndCurrentEdi
t() locktextboxes() End Sub
'cancel the changes being made to the current
record Private Sub CancelEdit_Click()
Handles CancelEdit.Click
BindingContext(DataSet11, "vehicle").CancelCurrent
Edit() locktextboxes() End Sub
8
Methods of BindingContext Object
  • AddNew
  • EndCurrentEdit
  • CancelCurrent Edit

Step1 Make changes to the dataset
9
Step 2 Update the Database
Project
database
dataset
Form1 Form2
invoice
customer
1
2
customer
invoice line item
part

resides in local machine
10
Step 2
11
Commit or Reject Changes to the Database
'send the changes made to the dataset to the
database Private Sub UpdateDatabase_Click()
Handles UpdateDatabase.Click
Adapter1.Update(DataSet11, "Vehicle")
End Sub
'cancel all the changes made to the dataset
since the last update Private Sub
CancelAll_Click() Handles CancelAll.Click
DataSet11.RejectChanges() End Sub
Write a Comment
User Comments (0)
About PowerShow.com