?
Solved

Adding Rows Through Windows Form to Table with Identity Column

Posted on 2006-06-26
2
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
vadim63 earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 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