troubleshooting Question

UNIQUE constraints

Avatar of mawingpui
mawingpuiFlag for Hong Kong asked on
C#Microsoft SQL Server 2005
2 Comments1 Solution302 ViewsLast Modified:
I have a Data Table and want to combine two column as unique pair in a table.
I search the MSDN library and find the following.


DataTable bookTable = new DataTable();
DataColumn bookTitle = bookTable.Columns.Add("BookTitle", typeof(string));
DataColumn bookEdition = bookTable.Columns.Add("BookEdition", typeof(string));

bookTable.Rows.Add("Computer Security Basics", "2000c");
bookTable.Rows.Add("ASP.NET", "2006");
bookTable.Rows.Add("Apache", "1998");
bookTable.Rows.Add("Computing Essentials 99", "1999");
bookTable.Rows.Add("Computing Essentials 2000", "2003 v2");
bookTable.Rows.Add("Java", "2003");
bookTable.Rows.Add("ASP.NET", "2007");

I add the following but seem not work..
bookTitle.Unique = true;
bookEdition.Unique = true;

Do you know the easy way to combine two column as unique pair, that is
PK(BookTitle, BookEdition)

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros