![Phân tích tư tưởng của nhân dân qua đoạn thơ: Những người vợ nhớ chồng… Những cuộc đời đã hóa sông núi ta trong Đất nước của Nguyễn Khoa Điềm](https://timtailieu.net/upload/document/136415/phan-tich-tu-tuong-cua-nhan-dan-qua-doan-tho-039-039-nhung-nguoi-vo-nho-chong-nhung-cuoc-doi-da-hoa-song-nui-ta-039-039-trong-dat-nuoc-cua-nguyen-khoa-136415.jpg)
Hướng Dẫn Thực Hành Winform - phần 5 ADO.NET (tt)
Số trang: 8
Loại file: pdf
Dung lượng: 334.57 KB
Lượt xem: 11
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Tham khảo tài liệu hướng dẫn thực hành winform - phần 5 ado.net (tt), công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Hướng Dẫn Thực Hành Winform - phần 5 ADO.NET (tt)Xây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh Dũng HƯ NG D N TH C HÀNH TU N 5 Ch : ADO.NET (tt) Ph n 2: Các thao tác k t n i ADO.NET s d ng c u trúc dòng l nh v i namespace System.Data. (K t n i v i Database SQL Server)1. Thi t k CSDL SQL Server như sau:a. T o databse v i tên DBHOCSINH, thi t k các table sau: HOCSINH STT Tên trư ng Ki u d li u Ghi chú 1 MaHS Nvarchar(20) PrimaryKey 2 TenHS Nvarchar(100) 3 NgaySinh Datetime 4 DiaChi Nvarchar(255) 5 DTB Real 6 MaLop Nvarchar(20) ForeignKey (tham chi u n Lop(MaLop) LOP STT Tên trư ng Ki u d li u Ghi chú 1 MaLop Nvarchar(20) PrimaryKey 2 TenLop Nvarchar(100) 3 SiSo smallint2. T o project m i: Thi t k l i Form “K t n i CSDL SQL Server” như màn hình sau:Xây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh Dũng Source code l p frmConnectionusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace QLHocSinh{ public partial class frmConnection : Form { //Khai báo bi n thành ph n public string sServerName = ; public string sDatabaseName = ; public string sUser = ; public string sPass = ; public frmConnection() { InitializeComponent(); } private void frmConnection_Load(object sender, EventArgs e) { txtServerName.Focus(); } private void cmdExit_Click(object sender, EventArgs e) { this.Close(); } private bool KiemTraDLHopLe() { if (txtServerName.Text.Trim().Length == 0)Xây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh Dũng { MessageBox.Show(Chưa nh p tên máy ch ., Thong bao loi, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } if (txtDBName.Text.Trim().Length == 0) { MessageBox.Show(Chưa nh p tên CSDL., Thong bao loi, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } return true; } private void cmdConnect_Click(object sender, EventArgs e) { if (!KiemTraDLHopLe()) return; sServerName = txtServerName.Text.Trim(); sDatabaseName = txtDBName.Text.Trim(); sUser = txtUser.Text.Trim(); sPass = txtPass.Text.Trim(); frmHocSinh frm = new frmHocSinh(); //Ki m tra k t n i CSDL if (!frm.connect(sServerName, sDatabaseName, sUser, sPass)) { MessageBox.Show(K t n i n máy ch không thành công., Thong bao loi, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } MessageBox.Show(K t n i n máy ch thành công., Thong bao, MessageBoxButtons.OK, MessageBoxIcon.Information); frm.Show(); this.Hide(); } }}Xây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh DũngThi t k form nh p thông tin h c sinh như sau: K t qu màn hình khi ch y: DataGridViewXây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh Dũng k t n i v i CSDL SQL Server dùng namespace: using System.Data.SqlClient;Source code l p Màn hình nh p thông tin h c sinh:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace QLHocSinh{ public partial class frmHocSinh : Form { private SqlConnection connection; private SqlDataAdapter adapter; private DataSet dataSet; private SqlCommand command; private string maHS, tenHS, diachi, malop; private float dtb; private DateTime ngaysinh; public frmHocSinh() { InitializeComponent(); } public bool connect(string sServerName, string sDBName, string sUser, str ...
Nội dung trích xuất từ tài liệu:
Hướng Dẫn Thực Hành Winform - phần 5 ADO.NET (tt)Xây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh Dũng HƯ NG D N TH C HÀNH TU N 5 Ch : ADO.NET (tt) Ph n 2: Các thao tác k t n i ADO.NET s d ng c u trúc dòng l nh v i namespace System.Data. (K t n i v i Database SQL Server)1. Thi t k CSDL SQL Server như sau:a. T o databse v i tên DBHOCSINH, thi t k các table sau: HOCSINH STT Tên trư ng Ki u d li u Ghi chú 1 MaHS Nvarchar(20) PrimaryKey 2 TenHS Nvarchar(100) 3 NgaySinh Datetime 4 DiaChi Nvarchar(255) 5 DTB Real 6 MaLop Nvarchar(20) ForeignKey (tham chi u n Lop(MaLop) LOP STT Tên trư ng Ki u d li u Ghi chú 1 MaLop Nvarchar(20) PrimaryKey 2 TenLop Nvarchar(100) 3 SiSo smallint2. T o project m i: Thi t k l i Form “K t n i CSDL SQL Server” như màn hình sau:Xây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh Dũng Source code l p frmConnectionusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace QLHocSinh{ public partial class frmConnection : Form { //Khai báo bi n thành ph n public string sServerName = ; public string sDatabaseName = ; public string sUser = ; public string sPass = ; public frmConnection() { InitializeComponent(); } private void frmConnection_Load(object sender, EventArgs e) { txtServerName.Focus(); } private void cmdExit_Click(object sender, EventArgs e) { this.Close(); } private bool KiemTraDLHopLe() { if (txtServerName.Text.Trim().Length == 0)Xây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh Dũng { MessageBox.Show(Chưa nh p tên máy ch ., Thong bao loi, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } if (txtDBName.Text.Trim().Length == 0) { MessageBox.Show(Chưa nh p tên CSDL., Thong bao loi, MessageBoxButtons.OK, MessageBoxIcon.Stop); return false; } return true; } private void cmdConnect_Click(object sender, EventArgs e) { if (!KiemTraDLHopLe()) return; sServerName = txtServerName.Text.Trim(); sDatabaseName = txtDBName.Text.Trim(); sUser = txtUser.Text.Trim(); sPass = txtPass.Text.Trim(); frmHocSinh frm = new frmHocSinh(); //Ki m tra k t n i CSDL if (!frm.connect(sServerName, sDatabaseName, sUser, sPass)) { MessageBox.Show(K t n i n máy ch không thành công., Thong bao loi, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } MessageBox.Show(K t n i n máy ch thành công., Thong bao, MessageBoxButtons.OK, MessageBoxIcon.Information); frm.Show(); this.Hide(); } }}Xây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh DũngThi t k form nh p thông tin h c sinh như sau: K t qu màn hình khi ch y: DataGridViewXây d ng ph n m m hư ng i tư ng GVHD: Tr n Anh Dũng k t n i v i CSDL SQL Server dùng namespace: using System.Data.SqlClient;Source code l p Màn hình nh p thông tin h c sinh:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace QLHocSinh{ public partial class frmHocSinh : Form { private SqlConnection connection; private SqlDataAdapter adapter; private DataSet dataSet; private SqlCommand command; private string maHS, tenHS, diachi, malop; private float dtb; private DateTime ngaysinh; public frmHocSinh() { InitializeComponent(); } public bool connect(string sServerName, string sDBName, string sUser, str ...
Tìm kiếm theo từ khóa liên quan:
thủ thuật lập trình lập trình căn bản winform C# thực hành winform lập trình hướng đối tượngTài liệu liên quan:
-
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 282 0 0 -
114 trang 252 2 0
-
80 trang 229 0 0
-
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 223 0 0 -
Thủ thuật giúp giải phóng dung lượng ổ cứng
4 trang 217 0 0 -
101 trang 205 1 0
-
Hướng dẫn lập trình với Android part 4
5 trang 156 0 0 -
Giáo trình Lập trình C căn bản - HanoiAptech Computer Education Center
136 trang 137 0 0 -
14 trang 137 0 0
-
142 trang 130 0 0