开发者

NoNullAllowedException error when inserting data to a datagridview despite identity column is set to be auto-incremented

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 d开发者_如何学JAVAo?I use C# and SQL server 2008

Cheers


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜