Unique field combination constraints

C

cpnet

Say I table, "Stuff". It has 2 columns: "StuffId", "Description", and
"StuffId" is a primary key.

I know how to set an XSD schema that defines a DataSet that will hold this
table. However, if I want to add an additional constraint where
"Description" must be unique, how do I do that? Do I have to rely on the
database to enforce such a constraint, or code something into the
RowChanged/RowChanging events for the DataTable? To make things as easy as
possible for the user, I'd like not to have to wait for the database to
throw an error if this constraint is violated. It would be easiest if I
could define this in the xsd schema, but there doesn't seem to be a way.

What's the standard way to handle this sort of thing when dealing with
disconnected datasets?

Thanks
 
C

cpnet

I found it... I need to create a new "Key" with the column(s) I want to be
unique, but I just don't mark it as a DB primary key in the XSD designer.
It's a bit odd since on the diagram it ends up looking like a primary key,
but it seems to work.
 

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