This tutorial is all about Removing Users.
Today, I’m going to teach you on how to remove the data in MySQL Database. Deleting or removing records is not required in a system but if you are a programmer you have to create this method when developing a system because you have to undergo in many testing and data entry into a database. This will be helpful to a programmer like you, to apply this function. I will add another function for clearing the text in the Textboxes.
Now, Let’s Begin:
Open the file of “EmployeesInformationSystem” that you had created. Drag two Buttons on the Form and name it “btnNew” and “btnDelete” . Set the Form just like this.
After setting up the Form, double click the “New” Button to fire the
click event handler of it and call the method for clearing the text in the TextBoxes that you had created.
- Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
- End Sub
Go back to the “ManageUserForm” Form Design and double click the “Delete” Button to fire the
click event handler of it. After that, add the following code for deleting and refreshing the records in the MySQL Database.
- Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
- query = "DELETE FROM <code>useraccounts</code> WHERE USER_ID='" & dtgList.CurrentRow.Cells(0).Value & "'"
- 'RETRIEVING DATA
- 'STORE A SLECT QUERY IN A STRING VARIABLE
- query = "SELECT <code>USER_ID</code>, <code>UNAME</code> AS NAME, <code>USERNAME</code>, <code>TYPE</code> FROM <code>useraccounts</code> "
- 'SET A RETRIEVE METHOD THAT YOU HAD CREATED.
- mysqlRetrieve(query, dtgList)
- End Sub
Readers might read also: