Professional Documents
Culture Documents
Lab 05 - Connect Database-V2
Lab 05 - Connect Database-V2
THỰC HÀNH SỐ 05
--
create table tblStyle(
ID int identity(1,1) primary key,
nameStyle nvarchar(150)
)
--
THỰC HÀNH WEB
--
--
create table tblProduct(
ID int identity(1,1),
codeProduct char(20) primary key,
nameProduct nvarchar(100),
descriptionProduct nvarchar(max),
idSup int,
quantityProductInput int,
priceProductInput float,
colorPro varchar(50),
sizePro varchar(10),
material nvarchar(50),
genderUse nvarchar(5),
IDStyle int,
imageProduct1 nvarchar(max),
imageProduct2 nvarchar(max),
imageProduct3 nvarchar(max),
foreign key (IDSup) references tblSupplierProduct(IDSup),
foreign key(IDStyle) references tblStyle(ID),
)
--
Trên Visual Studio > menu View > chọn SQL Server Object Explorerr
Kết nối với SQL:
Nhấp phải chuột vào thư mục Databases > Add New Database
Nhấp chuột phải vào tên database DBQLBanHang -> New Query ->
Copy paste các lệnh tạo table và chạy từng bảng.
Nhấp phải chuột vào thư mục Model -> Add -> New Item
THỰC HÀNH WEB
THỰC HÀNH WEB
THỰC HÀNH WEB
Server name
Chọn: Database
Bạn muốn biết tên datasese dùng để truy vấn các lớp trong Model thì có 2
cách:
Cách 1:
Cách 2:
THỰC HÀNH WEB
Nhấp phải chuột vào thư mục Controller -> New -> Controller
Đặt tên là StaffController.cs