views:

64

answers:

2

hi

I have put a DataGridView in my program such that this DataGridView is corresponding to a dataset of one table and this table has a auto-incremented identity column(also,this column is set to be primary key).

This identity column is not visible in DataGridView and when a user fills other cells and clicks "save",NoNullAllowedException occurs.

Why?I want to allow user to just insert data(not another modification)

How can I do?I use C# and SQL server 2008

Cheers

A: 

What's your target table definition? Does any column have the NOT NULL restriction?

MPelletier
yesAs I said before,the identity column is set to be primary key,also.
Saeidmscs
Fine for the primary key, but what about the others? In theory this exception is raised when you submit nulls in a Not Null field. Are you trying to submit nulls there?
MPelletier
A: 

Look at your table and find all the columns that are NOT NULL and make sure the form is posting something into those fields.

If it really is just the Primary Key that's causing the issue verify that it works by posting data directly from SQL server management studio with T-SQL Code (INSERT INTO) etc.

CaleyWoods