Lab Database Connection Csharp 4labs
Lab Database Connection Csharp 4labs
NET
LAB 1
I. Create Database
1. Create Database STUDENT_MANAGEMENT that contains table CLASS and
STUDENT
- Table CLASS
- Table STUDENT
- Table STUDENT
1
2
II. Connect to SQL Server Database
Design Form
C# code
III.
Query Data
3
Design Form
C# code
Design Form
4
C# Code
Design Form
ListBoxC# Code
6
7
Design Form
ListView
C# Code
8
9
10
11
LAB 2: Using SqlDataAdapter
Design Form
DataGridView
C# Code
12
13
14
15
16
- On the Save the Connection String to the Application
Configuration File page, click Next.
- On the Choose Your Database Objects page, click Next.
1
7
- Click Finish
- Click page Data Sources, the window looks like this:
2. Create form Student
18
- Choose DataGridView for the STUDENT table, drag and drop the STUDENT
table to the form.
- Choose Details for the STUDENT table, drag and drop the STUDENT table to
the form.
II. Data Binding with Controls in C#
Create a form to Show list of students by class
19
1. How to: Bind a Windows Forms ComboBox Control to Data - Create Data
Source: using Data Source Configuration Wizard - Select the cboClassID
ComboBox and follow the instructions below:
- Do the same with the cboClassName ComboBox
- Write code for the VIEW button
20
- III.
Search Form
21
LAB 4: HOW TO BUILD AND DEPLOY A THREE-LAYER
ARCHITECTURE APPLICATION WITH C#
1. Create the following form in a three-layer architecture application
-
When the user clicks the “View Student Table” button, the “Student” Table will be
displayed on the ListView.
- The solution of the application should be following:
22
2. Create the following form in a three-layer architecture application
23