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 .