System.Data Namespace DataRelation Class
Returns the UniqueConstraint for the relation.
Script |
[ UniqueConstraint variable = ] DataRelation.ParentKeyConstraint |
The property is read only with no default value.
This property is used to return the UniqueConstraint that ensures values in the parent column of a DataRelation are unique.
The following example gets the ParentKeyConstraint associated with the DataRelation.
private void GetParentKeyConstraint ( ) {
// get a DataRelation from a DataSet.
DataRelation dr = myDataSet.Relations [ "CustomerOrders" ];
// get the relation's parent key constraint.
UniqueConstraint pkCstrt = dr.ParentKeyConstraint;
// get the constraint's DataColumns
DataColumn [ ] cstrtCols = pkCstrt.Columns;
// print the column names.
int i;
for ( i = 0; i < cstrtCols.Length; i++ ) {
Response.Write ( cstrtCols [ ].ColumnName );
}
}
Private Sub GetParentKeyConstraint ( )
' get a DataRelation from a DataSet.
Dim dr As DataRelation = myDataSet.Relations ( "CustomerOrders" )
' get the relation's parent key constraint.
Dim pkCstrt As UniqueConstraint = dr.ParentKeyConstraint
' get the constraint's DataColumns
Dim cstrtCols ( ) As DataColumn = pkCstrt.Columns
' print the column names.
Dim i As Integer
For i = 0 to cstrtCols.GetUpperBound ( 0 )
Response.Write ( cstrtCols ( i ).ColumnName )
Next i
End Sub |
|
C# |
VB |
DataRelation Members AcceptRejectRule ChildKeyConstraint Rule