I have this code to insert values into a table:
conn.Open();
comm.CommandText = @"INSERT INTO ArticleBarCode(Code, Code_Article, BarCode, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn, IsDeleted)
VALUES (@code, @codearticle, @barcode, 1, @date, 1, @date, 0)";
comm.Parameters.AddWithValue("@code", next);
comm.Parameters.AddWithValue("@codearticle", code);
comm.Parameters.AddWithValue("@barcode", numbercode);
comm.Parameters.AddWithValue("@date", DateTime.Now);
comm.ExecuteNonQuery();
conn.Close();
But when I run it gives me this error:
The INSERT statement conflicts with the FOREIGN KEY constraint "FK_ArticleBarCode_Article". The conflict occurred in database "CardozuGestDB", table "dbo.Article", column 'Code'.
How can I resolve this?