DataTable Constraints

  • Thread starter Thread starter M Hyde
  • Start date Start date
M

M Hyde

What is the difference between adding a primary
key/unique constraint to a DataTable object using the
Constraint.Add method vs. using the PrimaryKey property
of the DataTable or Unique property of the DataColumn? Is
it redundant to use both? If so which method is
preferable?
 
If the column is a primary key, then use the PrimaryKey property; if the
column is not the key, but requires uniqueness, then add the constraint.
Simply requiring uniqueness is not the same as being a primary key, and the
framework will look at this property when it requires primary key
information on the table.

Steven Bras, MCSD
Microsoft Developer Support/Data Access Technologies

This posting is provided "AS IS" with no warranties, and confers no rights.

Microsoft Security Announcement: Have you installed the patch for Microsoft
Security Bulletin MS03-026?  If not Microsoft strongly advises you to
review the information at the following link regarding Microsoft Security
Bulletin MS03-026
http://www.microsoft.com/security/security_bulletins/ms03-026.asp and/or to
visit Windows Update at http://windowsupdate.microsoft.com to install the
patch. Running the SCAN program from the Windows Update site will help to
insure you are current with all security patches, not just MS03-026.
 
Back
Top