Creating a UniqueConstraint Object

Creating a UniqueConstraint Object In this section, you'll learn how to create a UniqueConstraint object. The UniqueConstraint constructor is overloaded as follows | Creating a UniqueConstraint Object In this section you ll learn how to create a UniqueConstraint object. The UniqueConstraint constructor is overloaded as follows UniqueConstraint DataColumn myDataColumn UniqueConstraint DataColumn myDataColumns UniqueConstraint DataColumn myDataColumn bool isPrimaryKey UniqueConstraint DataColumn myDataColumns bool isPrimaryKey UniqueConstraint string constraintName DataColumn myDataColumn UniqueConstraint string constraintName DataColumn myDataColumns UniqueConstraint string constraintName DataColumn myDataColumn bool isPrimaryKey UniqueConstraint string constraintName DataColumn myDataColumns bool isPrimaryKey UniqueConstraint string constraintName string columnNames bool isPrimaryKey where myDataColumn and myDataColumns are the DataColumn objects that you want to ensure are unique. constraintName is the name you want to assign to the ConstraintName property of your UniqueConstraint. isPrimaryKey indicates whether your UniqueConstraint is for a primary key. Before creating and adding a UniqueConstraint to a DataTable you first need a DataTable. The following example creates and populates two DataTable objects named customersDT and ordersDT the ordersDT object will be used later in the section Creating a ForeignKeyConstraint Object SqlCommand mySqlCommand SELECT CustomerlD CompanyName FROM Customers WHERE CustomerlD ALFKI SELECT OrderlD CustomerlD FROM Orders WHERE CustomerlD ALFKI SqlDataAdapter mySqlDataAdapter new SqlDataAdapter mySqlCommand DataSet myDataSet new DataSet myDataSet Table .TableName Customers Table1 .TableName Orders DataTable customersDT Customers DataTable ordersDT Orders The following example creates a UniqueConstraint object on the CustomerlD DataColumn of the customersDT DataTable and then .

Bấm vào đây để xem trước nội dung
TÀI LIỆU LIÊN QUAN
5    176    1
5    255    1
5    106    0
5    121    1
6    103    1
6    107    1
6    121    1
6    103    0
6    140    0
6    98    0
TÀI LIỆU MỚI ĐĂNG
48    96    1    26-06-2024
Đã 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.