In my first ADO.Net 2.0 project I'm trying to create a Windows Forms
application that allows updating customer records. These records are in
an SQL Server 2003 database, and I am using the VS.Net 2005 DataSet
Designer to create a typed DataSet and Customer TableAdapter. To start,
I just output the internal IDs of fields to TextBoxes on a form. So
far, so good.
One of the fields is for Language (English,
French, Spanish, etc.), and there is a database table with language
names and IDs. So I add a new Language TableAdapter and Relation to the
DataSet Designer. The Relation is:
Parent table:
Language
Child table: Customer
Key Column:
Language.languageID
Foreign Key Column:
Customer.languageID
Both Relation and Foreign Key
constraint
Update Rule: Cascade
Delete Rule:
Cascade
Accept/Reject Rule: None
Previewing
all TableAdapters look fine, and all customers have valid languageIDs. I create a Language ComboBox in my form, choose "Use Data bound items" and... where's Language? There are a few
other tables I'm going to be using, but no Language. There's even
another relation, but not the language one. Well, I'll leave it unbound
for now, run it, and...
A first chance exception of
type 'System.Data.ConstraintException' occurred in
System.Data.dll
...
Failed to enable constraints. One
or more rows contain values violating non-null, unique, or foreign-key
constraints.
It lies; all rows contain valid unique
data, and no constraint violations. I can run the SELECT commandText in
all DataAdapters on the database without errors. This only started to
happen after I added the Language table.
What am I doing wrong?