OOP Module9 HFEstrada Oct26
OOP Module9 HFEstrada Oct26
Declaration:
This learning module is an exclusive property of Dr. Yanga’s Colleges, Inc., as an essential part of the
REIMAGINED Learning Program for the Academic Year 2020-2021, and shall only be used by and for
DYCIans. No part of this learning module shall be reproduced, distributed, transmitted, and/or sold, without
the consent of DYCI.
MODULE 8
UPDATE AND DELETE RECORD
This module will help you acquire knowledge on how to update and delete single rec-
ord using VB.net and MySQL
Form.DialogResult Property
A DialogResult that represents the result of the form when used as a dialog box.
DialogResult Enum
Specifies identifiers to indicate the return value of a dialog box.
FIELDS
Abort 3 The dialog box return value is Abort (usually sent from a button labeled
Abort).
Cancel 2 The dialog box return value is Cancel (usually sent from a button
labeled Cancel).
Ignore 5 dialog box return value is Ignore (usually sent from a button la-
beled Ignore).
2
No 7 The dialog box return value is No (usually sent from a button labeled
No).
None 0 Nothing is returned from the dialog box. This means that the modal
dialog continues running.
OK 1 The dialog box return value is OK (usually sent from a button labeled
OK).
Retry 4 The dialog box return value is Retry (usually sent from a button la-
beled Retry).
Yes 6 The dialog box return value is Yes (usually sent from a button labeled
Yes).
3
Update Record from Text Box
Step1: Using the sear ch for m pr eviously cr eate in module 8, add two buttons and a
label
Delete (btndelete)
Update (btnupdate)
Label (lblid)
Step2: Add the following code to disable Delete and Update button to your
frmSearch_Load event
btnupdate.Enabled = False 'disabled update button
btndelete.Enabled = False 'disabled delete button
Step3: Add the following code to your button Back.
frmvbMySQL.Show()
frmvbMySQL.LoadRecord()
Step4: Add the following code to your btnSearch.
btnupdate.Enabled = True
btndelete.Enabled = True
4
Step5: Add the following code to your txtData keypress event.
btnupdate.Enabled = True
btndelete.Enabled = True
5
Step6: Add the following code to your delete button.
6
Step7: Add the following code to your clearData() procedure
7
Step2: Update your btnLoad as shown below:
8
Step4: Write the command for button update as shown below:
Note: Add .toString after .Value if you have empty column (dbNull) record
Step5: Write the command to delete selected record from your Data Grid
View
9
Step6: Add label (lblid) into your frmAddNewUser form and update the code
in your button save.
10
Update the command to your back button
11
Name: _____________________________________________ Rating: ________________
Year and Section:_____________ Professor / Instructor: __________________________
Due of Submission: _____________________________
1. Open the activity project created in module 8 than add to Button to your
main form: Update and Delete button
2. Add the functionality of the update button to update the record selected in
the DataGridView.
3. Add the functionality of the delete button to delete the record selected in the
DataGridView.
5. Add the functionality of the update button in the search form to update the
record based on the search result
6. Add the functionality of the delete button in the search form to delete the rec-
ord based on the search result
12
guru99.com. (2020, June 6). V B.NET Tutorial: Learn V B.Net programming. Retrieved
from https://www.guru99.com/vb-net-tutorial.html.
hscripts.com. (2020). V B.Net Tutorial - Microsoft Visual Basic Programming. Re-
trieved from https://www.hscripts.com/tutorials/vbnet/index.php.
Pepito, C. P. (2011). Itnroduction to V isual Basic 2008 Programming. Philippines: Na-
tional Book Store.
Tamayo, J. D., Taguinod, I. C., Gibaga, G. R., Malang, B. P., Macatangga, R. S., &
Casuco Jr., F. S. (2014). V B.Net Programming. Malabon City: Jimczyville Pub-
lications.
techotopia.com. (2020). V isual Basic Essentials. Retrieved from techotopia.com/
index.php/Visual_Basic_Essentials
tutorialspoint.com. (2020, June 6). V B.Net Programming Tutorial. Retrieved from
https://www.tutorialspoint.com/vb.net/index.htm.
vb.net-informations.com. (2020, June 6). V B.NET Tutorial. Retrieved from http://
vb.net-informations.com/.
vbtutor.net. (2020, June 6). V isual Basic 2008 Tutorial. Retrieved from https://
www.vbtutor.net/vb2008/vb2008tutor.html.
13