开发者

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

开发者 https://www.devze.com 2023-01-09 18:50 出处:网络
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 prima

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

精彩评论

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