14-Removing Users

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.
userregformdeleteform
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.
[vbnet]
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
clearingObject(Me)
End Sub
[/vbnet]
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.
[vbnet]
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
query = “DELETE FROM `useraccounts` WHERE USER_ID='” & dtgList.CurrentRow.Cells(0).Value & “‘”
mysqlDelete(query)

‘RETRIEVING DATA
‘STORE A SLECT QUERY IN A STRING VARIABLE
query = “SELECT `USER_ID`, `UNAME` AS NAME, `USERNAME`, `TYPE` FROM `useraccounts` ”
‘SET A RETRIEVE METHOD THAT YOU HAD CREATED.
mysqlRetrieve(query, dtgList)
End Sub
[/vbnet]

 

Readers might read also:

 

 

Leave a Comment