Adding Rows Through Windows Form to Table with Identity Column
Posted on 2006-06-26
Hi boys and girls,
I have a windows app with a form. I've dragged and dropped a table from my dataset onto the form. VS 2005 kindly adds a binding navigator that allows you to add, delete and save records. Very nice.
The problem comes when I try to add a row to the table through the form. The primary key of the table is an auto-incrementing identity column, so I don't want the form to pass a null to the table. Wwhen it does so, of course, I get the "column x does not accept nulls" error.
How do I tell the form not to insert a value for the identity column? Do I need to use a different binding source for inserts vs. updates and deletions (where the primary key value is required to update the row)?