I m using SQL Server 2014 and have a simple 2 column tabel:
/****** Object: Table [dbo].[AAA_QualityCode] Script Date: 7-12-2023 17:43:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AAA_QualityCode](
[Code] [int] NOT NULL,
[Description] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_AAA_QualityCode] PRIMARY KEY CLUSTERED
(
[Code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
I am using LLBLGen 5.8.6 and generate SelfServicing code for asp.net 4.8.
When I run the following code I get an exception:
QualityCodeEntity qa = new QualityCodeEntity();
qa.Code = -1;
qa.Description = "Ongedefinieerd";
qa.Save();
According to the exception info, the following Query is executed:
Query: INSERT INTO [HITc_Configuration].[dbo].[AAA_QualityCode] ([Description]) VALUES (@p2) ;SELECT @p1 = SCOPE_IDENTITY()
Parameter: @p1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Output. Value: <undefined value>.
Parameter: @p2 : AnsiString. Length: 50. Precision: 0. Scale: 0. Direction: Input. Value: "Ongedefinieerd".
The exception created is because the Code field is null instead of -1.
What could be wrong?