Solved

Adding Rows Through Windows Form to Table with Identity Column

Posted on 2006-06-26
2
206 Views
Last Modified: 2010-04-23
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)?

TIA!
0
Comment
Question by:seadriver
2 Comments
 
LVL 10

Accepted Solution

by:
vadim63 earned 500 total points
ID: 16986633
Shouldn't be any problems. Can you see "AutoIncrement" has "true" value in Dataset Designer?
0
 

Author Comment

by:seadriver
ID: 16987120
Thanks, just needed to know where to look.

Now I'm getting errors on all the non-null columns that don't have related form controls setting values for them.  I'd like the database to set the default value, not the form, but for the heck of it, I went ahead and set the Default Value of the Status column to 'A' in the property box.  VS 2005 accepted the entry, then refused to display the form or the dataset designer, telling me that Status had an invalid default value.

How can a tool blow up on an entry it allowed you to make in the form designer???

Oh well, that's another issue.  Seems to me that this thing really isn't ready for prime time yet...

Thanks again!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now