05-Retrieving Employees

0
357

This tutorial is all about Retrieving Employees.
Today, I’m going to teach you how to retrieve data in the database. Retrieving data means that, the data obtain from a database management system. In order to retrieve the data in the database that you desire, you have to present a set of criteria by a query.

So, let’s begin:

Open the file “EmployeesInformationSystem” that you had created. After that, select the TabControl as click the TabPage2, then drag a DataGridView and place it into the center of the TabPage. It will look like this.
employeesregformretrivedata
Now, select the TabControl and go to the properties. In the properties, select the events that looks like a lightning and double click the selected to fire the Selected event handler of the tabcontrol.
employeesregformretrivedataevents
In the TabControl1_Selected, you have to set a code for setting up the properties and display the records in the DataGridView.

  1. Private Sub TabControl1_Selected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles TabControl1.Selected
  2. With DataGridView1
  3. 'SET THIS PROPERTIES TO DETERMINE THE COLUMN WITH AND SPECIFYING HOW ITS ADJUST
  4. .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
  5. 'SET THIS PROPERTIES TO DETERMINE THE HIEGHT OF THE ROWS AND SPECIFYING HOW ITS ADJUST
  6. .AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
  7. 'SET THE FULL ROW SELECTION MODE
  8. .SelectionMode = DataGridViewSelectionMode.FullRowSelect
  9. 'SET THIS PROPERTIES SO THAT YOU CAN'T ADD ROWS IN THE DATAGRIDVIEW
  10. .AllowUserToAddRows = False
  11. End With
  12. 'SET THIS QUERY TO RETRIEVE THE DATA IN THE DATABASE
  13. query = "SELECT E.`EMPLOYEE_ID`, concat(`LAST_NAME`,', ',`FIRST_NAME`,' ', `MIDDLE_NAME`) as NAME" & _
  14. ", `ADDRESS`, `GENDER`, `AGE`,`D_HIRED` AS HIRED_DATE,`D_RATE` AS DAILY_RATE,`W_STATUS` AS STATUS " & _
  15. " FROM `employees` 'CALL THE METHOD THAT YOU HAVE CREATED FOR RETRIEVING DATA IN THE DATABASE
  16. mysqlRetrieve(query, DataGridView1)
  17. End Sub

 

Readers might read also:

 

Facebook Comments
(Visited 30 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here