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.
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.
TabControl1_Selected, you have to set a code for setting up the properties and display the records in the DataGridView.
[vbnet] Private Sub TabControl1_Selected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles TabControl1.Selected
‘SET THIS PROPERTIES TO DETERMINE THE COLUMN WITH AND SPECIFYING HOW ITS ADJUST
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
‘SET THIS PROPERTIES TO DETERMINE THE HIEGHT OF THE ROWS AND SPECIFYING HOW ITS ADJUST
.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
‘SET THE FULL ROW SELECTION MODE
.SelectionMode = DataGridViewSelectionMode.FullRowSelect
‘SET THIS PROPERTIES SO THAT YOU CAN’T ADD ROWS IN THE DATAGRIDVIEW
.AllowUserToAddRows = False
‘SET THIS QUERY TO RETRIEVE THE DATA IN THE DATABASE
query = “SELECT E.
MIDDLE_NAME) as NAME” & _
D_HIRED AS HIRED_DATE,
D_RATE AS DAILY_RATE,
W_STATUS AS STATUS ” & _
employees ‘CALL THE METHOD THAT YOU HAVE CREATED FOR RETRIEVING DATA IN THE DATABASE
Readers might read also: