12-Searching Users

0
425

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.
[vbnet] ‘ADDING THE ITEMS IN THE COMBOBOX
With cboCateg.Items
.Add(“ID”)
.Add(“NAME”)
End With
[/vbnet] 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.
[vbnet] Private Sub txtseaarch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtseaarch.TextChanged
If cboCateg.Text = “ID” Then
‘STORE A SLECT QUERY IN A STRING VARIABLE
query = “SELECT USER_ID, UNAME AS NAME, USERNAME, TYPE FROM useraccounts” & _
” WHERE USER_ID LIKE ‘%” & txtseaarch.Text & “%'”
‘SET A RETRIEVE METHOD THAT YOU HAD CREATED.
mysqlRetrieve(query, dtgList)
ElseIf cboCateg.Text = “NAME” Then
‘STORE A SLECT QUERY IN A STRING VARIABLE
query = “SELECT USER_ID, UNAME AS NAME, USERNAME, TYPE FROM useraccounts” & _
” WHERE UNAME LIKE ‘%” & txtseaarch.Text & “%'”
‘SET A RETRIEVE METHOD THAT YOU HAD CREATED.
mysqlRetrieve(query, dtgList)
End If
End Sub
[/vbnet]

 

Readers might read also:

 

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.