'Cannot insert the value NULL into column 'GroepID', table 'C:\USERS\ALAINDEVRIJ\SOURCE\REPOS\KILLER APP FUN 12\BOWLINGSCORE\BIN\DEBUG\DATABASE1.MDF.dbo.Reservering'; column does not allow nulls. INSERT fails.
The statement has been terminated.'
i don't what value i should give because i want to insert this.
SqlConnection data = new SqlConnection(connectionstring);
data.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO Reservering(Banen,Tijdsduur,Datum,GroepID) VALUES (@Tijdsduur,@Banen, @Datum,@GroepID)", data);
cmd.Parameters.AddWithValue("@Tijdsduur", numtijd.Value);
cmd.Parameters.AddWithValue("@Banen", numaantbn.Value);
cmd.Parameters.AddWithValue("@Datum", SqlDbType.Date).Value= dateTimePicker1.Value.Date;
cmd.Parameters.AddWithValue("@GroepID", )
cmd.ExecuteScalar();
data.close();
What I have tried:
this is my table:
CREATE TABLE [dbo].[Reservering] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[GroepID] INT NOT NULL,
[Datum] DATE NOT NULL,
[Tijdsduur] INT NOT NULL,
[Banen] INT NOT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT ReserveringFK FOREIGN KEY ([GroepID]) REFERENCES [dbo].[Groep] ([Id])