Question

I am looking now for like an hour for a solution for my problem.

I have a SQL Server database table which the script is like this:

CREATE TABLE [dbo].[Table] (
    [Id]                      BIGINT NOT NULL IDENTITY,
    [Name]                    NVARCHAR (100)  NULL, ........

With C# I am trying to insert values in my database using a DataGridView which I created automatically with Visual Studio 2012.

Now when I try to insert some value using the binding navigator, I get the NoNullAllowedException on the ID. Why? I don't understand why this doesn't work.

I hope you can help me and thank you.

Good Day

Greetings

Was it helpful?

Solution

Problem : you might be trying to insert value for IDENTITY column.

Solution : you should completly omit the value for IDENTITY column while inserting the data.

because IDENTITY columns willbe inserted by default.

Try This:

INSERT INTO myTable(Name)
 Values('somevalue');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top