DataTable Constraints

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?
 
S

Steven Bras [MS]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top