-
Notifications
You must be signed in to change notification settings - Fork 14
Description
I have been exploring this project and have learned much from it.
When I tried applying the same logic to my own data, I found if the insert of the new record failed, a second set of parameters is generated, so even f you correct the error, the insert fails the next time due to the extra parameters.
To repeat this with your app, I altered the Employee table so it would only accept 15 characters in the City field.
Inserting a record with a City with more than 15 characters would then fail. Here is the from the SQL Trace showing the insert attempt:
_exec sp_executesql N'SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
INSERT INTO [Employees] ([Id], [City], [CreatedAt], [EmployeName], [Gender], [LastUpdatedAt])
VALUES (@p0, @p1, @p2, @p3, @p4, @p5);
',N'@p0 uniqueidentifier,@p1 nvarchar(4000),@p2 datetime2(7),@p3 nvarchar(4000),@p4 nvarchar(4000),@p5 datetime2(7)',@p0='78A3B3B6-5C52-498A-AF7F-A8621FB8FC9D',@p1=N'12345678901234567890',@p2='2025-12-03 04:34:55.5541909',@p3=N'Bob JOnes',@p4=N'Male',@p5='2025-12-03 04:34:57.4031299'_
If I shorten the City field to less than 15 characters, it still fails, but this time due to the extra parameters.
_exec sp_executesql N'SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
INSERT INTO [Employees] ([Id], [City], [CreatedAt], [EmployeName], [Gender], [LastUpdatedAt])
VALUES (@p0, @p1, @p2, @p3, @p4, @p5),
(@p6, @p7, @p8, @p9, @p10, @p11);
',N'@p0 uniqueidentifier,@p1 nvarchar(4000),@p2 datetime2(7),@p3 nvarchar(4000),@p4 nvarchar(4000),@p5 datetime2(7),@p6 uniqueidentifier,@p7 nvarchar(4000),@p8 datetime2(7),@p9 nvarchar(4000),@p10 nvarchar(4000),@p11 datetime2(7)',@p0='03250FFD-3E8C-43E1-B22D-620C8022BB9F',@p1=N'0987654321',@p2='2025-12-03 04:43:29.7491975',@p3=N'Bob JOnes',@p4=N'Male',@p5='2025-12-03 04:43:34.9771688',@p6='78A3B3B6-5C52-498A-AF7F-A8621FB8FC9D',@p7=N'12345678901234567890',@p8='2025-12-03 04:34:55.5541909',@p9=N'Bob JOnes',@p10=N'Male',@p11='2025-12-03 04:34:57.4031299'_
If you attempt to save the record again, it will generate another set of parameters.
Also, even if you close the create form, and reopen it, the previous parameters are still in place, and the next "Create" attempt will give an extra set of parameters.
I'm thinking the issue may be in the Exception handling. Could you adjust your app to be able to recover from an insert error to allow the user to correct the data, and attempt the Update without the creation of the additional parameters?