12-Searching Users

0
309

This tutorial is all about Searching Users.
In this tutorial, I’m going to teach you how to search the data in the MySQL Database. With this, you can search the user’s records that you have saved in the database. I used a TextBox with a ComboBox for choosing the category in searching the user’s records.

 

 

Let’s begin:

 

 

Open the file of “EmployeesInformationSystem” and click the Form Design of a “ManageUserForm“. After that, drag a GroupBox and drag a TextBox and a ComboBox inside of it. It will looks like this.
userregformsearchform
After adding all the objects that are needed, double click the Form and add the code for adding the items in the ComboBox on the first load of the Form.

  1. 'ADDING THE ITEMS IN THE COMBOBOX
  2. With cboCateg.Items
  3. .Add("ID")
  4. .Add("NAME")
  5. End With

Go back to the Form Design of “ManageUserForm” and double click the TextBox inside the GroupBox to fire the TextChanged event handler of it. Add the code for searching the records of the users in the MySQL Database.

  1. Private Sub txtseaarch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtseaarch.TextChanged
  2. If cboCateg.Text = "ID" Then
  3. 'STORE A SLECT QUERY IN A STRING VARIABLE
  4. query = "SELECT `USER_ID`, `UNAME` AS NAME, `USERNAME`, `TYPE` FROM `useraccounts`" & _
  5. " WHERE USER_ID LIKE '%" & txtseaarch.Text & "%'"
  6. 'SET A RETRIEVE METHOD THAT YOU HAD CREATED.
  7. mysqlRetrieve(query, dtgList)
  8. ElseIf cboCateg.Text = "NAME" Then
  9. 'STORE A SLECT QUERY IN A STRING VARIABLE
  10. query = "SELECT `USER_ID`, `UNAME` AS NAME, `USERNAME`, `TYPE` FROM `useraccounts`" & _
  11. " WHERE UNAME LIKE '%" & txtseaarch.Text & "%'"
  12. 'SET A RETRIEVE METHOD THAT YOU HAD CREATED.
  13. mysqlRetrieve(query, dtgList)
  14. End If
  15. End Sub

 

Readers might read also:

 

Facebook Comments
(Visited 32 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here