I'd hoped that the ADO.NET DataSets would import/inherit/read the database constraints and allow those to be enforced on the client side. However, my experimentation seems to indicate that this is not the case.
Using the Northwind customers table with the following constraints:
ALTER TABLE [dbo].[Customers] ADD
CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
([CustomerID]
) ON [PRIMARY] ,
CONSTRAINT [CK_ContactRequired] CHECK (len([ContactName]) > 0)
And using a SqlCommand object, SqlConnection object and SqlDataAdapter to fill the DataSet, the Constraints.count is zero, and I can add all the records I want with a blank contact and duplicate CustomerID values.
In another thread on this topic I note that Bonnie Berent reported that she's seeing the same behavior that I am, but Rick Strahl implies that his DataSets/DataTables are indeed picking up the constraints from the underlying tables.
Any light shed would be appreciated...
>>-Steve->>
Steve Sawyer
Geeks and Gurus, Inc.