Bài giảng Lập trình trên Windows với Microsoft.Net - Chương 10 - Trần Bá Nhiệm

SqlDataAdapter

 Bộ lọc dữ liệu.

 Phân trang dữ liệu.

 Phương thức

fill(datasource);

fill(datasource,start,number,”tablename”)

pdf 11 trang yennguyen 1340
Bạn đang xem tài liệu "Bài giảng Lập trình trên Windows với Microsoft.Net - Chương 10 - Trần Bá Nhiệm", để tải tài liệu gốc về máy hãy click vào nút Download ở trên

Tóm tắt nội dung tài liệu: Bài giảng Lập trình trên Windows với Microsoft.Net - Chương 10 - Trần Bá Nhiệm

Bài giảng Lập trình trên Windows với Microsoft.Net - Chương 10 - Trần Bá Nhiệm
Lập trình trên Windows 
với Microsoft® .NET
Giảng viên: ThS. Trần Bá Nhiệm
SqlDataAdapter
 Bộ lọc dữ liệu.
 Phân trang dữ liệu.
 Phương thức 
fill(datasource);
fill(datasource,start,number,”tablename”)
SqlCommand
 Thực thi câu lệnh SQL.
 Phương thức :
ExecuteNonQuery()
ExecuteScala()
ExecuteReader() 
DataSet
 Chứa dữ liệu trả về từ DataAdapter.
 “Cơ sở dữ liệu thu nhỏ”.
 Gồm các đối tượng :
- DataTable
- DataRelation
DataSet
 Mô hình DataSet
DataTable
 Chứa dữ liệu trả về DataSet hoặc 
DataAdapter.
 Gồm các đối tượng :
- DataColumn
- DataRow
Tạo một DataTable
 myTable.Columns.Add("ItemID",Type.GetType("System.Int
32"));
 myTable.Columns.Add("ItemName",Type.GetType("Syste
m.String"));
 myTable.Columns.Add("Quantity",Type.GetType("System.I
nt32"));
 myTable.Columns.Add("Quantity",Type.GetType("System.f
loat"));
 // thêm column mới vào table 
 myTable.Columns.Add(myColumn); 
 myTable.Columns.Add("SubTotal",Type.GetType("System.
Int32"),"Quantity*Price");
 myTable.PrimaryKey = new 
DataColumn[]{myTable.Columns[0]};
Chèn dữ liệu vào DataTable
 // Thêm 10 dòng vào Table
 DataRow myRow; 
 for(int i = 0; i < 10; i++)
 { 
 myRow = myTable.NewRow(); 
 myRow["ItemID"] = i + 1; 
 myRow["Price"] = i*2+1; 
 myRow["ItemName"] = (60+i); 
 myRow["Quantity"] = i + 1; 
 myTable.Rows.Add(myRow); 
 }
DataView
 Dùng để quản lý và thao tác dữ liệu trong 
DataTable
 Dùng để lọc , sắp xếp dữ liệu trong 
DataTable
DataView
DataBinding
 Hiển thị dữ liệu trong DataTablevào các 
control ( TextBox, ComboBox, DataGrid)
 Gồm 2 loại chính :
- Binding Sample
- Binding Complex

File đính kèm:

  • pdfbai_giang_lap_trinh_tren_windows_voi_microsoft_net_chuong_10.pdf