TAILIEUCHUNG - Building a DataSet Programmatically

[ Team LiB ] Recipe Building a DataSet Programmatically Problem You want to build a DataSet programmatically—including adding tables, columns, primary keys, and relations—from a schema that you have designed. | Team LiB Recipe Building a DataSet Programmatically Problem You want to build a DataSet programmatically including adding tables columns primary keys and relations from a schema that you have designed. Solution The following example shows how to build a complex DataSet programmatically including how to build and add tables columns primary key constraints relations and column mappings. Use this as a template for building your own DataSet. The sample code creates a DataSet. A DataTable object is created representing the Orders table in Northwind. Columns are added including the auto-increment primary key to the table. The table is added to the DataSet. The process is repeated for a DataTable representing the Order Details table in Northwind. A DataRelation is created relating the two tables. Finally the tables are filled with data from Northwind. The C code is shown in Example 2-2. Example 2-2. File Namespaces variables and constants using System using using using . . . Create the DataSet. DataSet ds new DataSet MyDataSet Build the Orders parent table. DataTable parentTable new DataTable Orders DataColumnCollection cols Add the identity field. DataColumn column OrderID typeof true -1 -1 Add the other fields. CustomerID typeof .MaxLength 5 EmployeeID typeof OrderDate typeof RequiredDate typeof ShippedDate typeof ShipVia typeof Freight typeof ShipName typeof .MaxLength 40 ShipAddress typeof .MaxLength 60 ShipCity typeof .MaxLength 15 ShipRegion typeof .MaxLength 15 ShipPostalCode typeof .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.