Đang chuẩn bị liên kết để tải về tài liệu:
Creating Constraints, PrimaryKeys, Relationships Based on Multiple Columns

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

[ Team LiB ] Recipe 6.8 Creating Constraints, PrimaryKeys, Relationships Based on Multiple Columns Problem You need to create a constraint, primary key, or a relationship between two tables in a DataSet using more than one column. Solution Use the System.Data. | Team LiB Recipe 6.8 Creating Constraints PrimaryKeys Relationships Based on Multiple Columns Problem You need to create a constraint primary key or a relationship between two tables in a DataSet using more than one column. Solution Use the System.Data.UniqueConstraint and System.Data.ForeignKeyConstraint types. The sample code creates a DataSet containing two tables Parent and Child. A multicolumn unique constraint and primary key are created for the Parent table. A multicolumn foreign-key constraint is created on the Child table. Finally a DataRelation between the primary key in the Parent table and the foreign key in the Child table is created. The C code is shown in Example 6-26. Example 6-26. File MultiColumnConstraintAndRelationForm.cs Namespaces variables and constants using System using System.Text using System.Data . . . StringBuilder result new StringBuilder DataSet ds new DataSet Create the parent table. result.Append Creating parent table. Environment.NewLine DataTable dtParent new DataTable Parent DataColumnCollection pCols dtParent.Columns pCols.Add ParentKey1 typeof Int32 pCols.Add ParentKey2 typeof lnt32 pCols.Add ParentData1 typeof String pCols.Add ParentData2 typeof String Set the multicolumn unique constraint. result.Append Creating unique constraint on parent table. Environment.NewLine dtParent.Constraints.Add new UniqueConstraint UConstraint new DataColumn pCols ParentKey1 pCols ParentKey2 false Set the multicolumn primary key. result.Append Creating primary key on parent table. Environment.NewLine dtParent.PrimaryKey new DataColumn pCols ParentKey1 pCols ParentKey2 Add the parent table to the DataSet. ds.Tables. Add dtParent Create the child table. result.Append Creating child table. Environment.NewLine DataTable dtChild new DataTable Child DataColumnCollection cCols dtChild.Columns cCols.Add ChildIndex1 typeof Int32 .Unique true cCols.Add ParentKey1 typeof Int32 cCols.Add ParentKey2 typeof lnt32 cCols.Add ChildData1 typeof String cCols.Add .

Đã 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.