Greetings experts,
I am pretty stumped with this Stored Procedure.
I have an ASP.NET web form that dynamically creates rows so user can add as many records as possible.
By default, the first row is created. Once user fills out the cells in that row, s/he clicks to add another row.
The problem we are having now is that when the records are submitted to the database, only the first row gets inserted into the database. Any additional rows are ignored.
Can someone please help to get this resolved?
I have been stumped on this issue now for two days.
Here is my current SP:
ALTER PROCEDURE [dbo].[sp_AircraftSchedule]
@pid int,
@txYr smallint,
@ptype varchar(50),
@regno varchar(50),
@city varchar(50),
@cnty varchar(50),
@state varchar(50),
@mfgMake varchar(50),
@mfgModel varchar(50),
@yrBuilt int,
@SN varchar(50),
@dtePurchased date,
@aCost decimal(18,2),
@issues varchar(50),
@issuedetails varchar(250),
@hrsbtwn varchar(50),
@lastsince varchar(50),
@LasthrOv varchar(50),
@totHrsOnAifm varchar(50),
@AvionExtrEq varchar(500),
@fdate datetime,
@tID int
AS
BEGIN
SET NOCOUNT ON;
if exists (select * from [AircraftScheduleE] where pid = @pid AND TaxYear =@txYr AND Registration_No = @regno)
begin
UPDATE [dbo].[AircraftScheduleE]
SET [TaxYear] = @txYr,
[PurchaseType] = @ptype,
[Registration_No] = @regno,
[City] = @city,
[County] = @cnty,
[State] = @state,
[MFG_Make] = @mfgMake,
[MFG_Model] = @mfgModel,
[Year_Built] = @yrBuilt,
[SerialNumber] = @SN,
[DatePurchased] = @dtePurchased,
[Aircraft_Cost] = ISNULL(@aCost,0),
[aircraftissues] = @issues,
[IssueDetails] = @issuedetails,
[Hours_BTW_Overall] = @hrsbtwn,
[Hours_Last_Since] = @lastsince,
[Last_Hour_Overhauled] = @LasthrOv,
[Total_HoursOnAirframe] = @totHrsOnAifm,
[Avionics_Extra_Equip] = @AvionExtrEq,
[FileDate] = @fdate
where pid = @pid AND TaxYear =@txYr AND Registration_No = @regno
end
else
begin
INSERT INTO [dbo].[AircraftScheduleE]
(
[PID],
[TaxYear],
[PurchaseType],
[Registration_No],
[City],
[County],
[State],
[MFG_Make],
[MFG_Model],
[Year_Built],
[SerialNumber],
[DatePurchased],
[Aircraft_Cost],
[aircraftissues],
[IssueDetails],
[Hours_BTW_Overall],
[Hours_Last_Since],
[Last_Hour_Overhauled],
[Total_HoursOnAirframe],
[Avionics_Extra_Equip],
[FileDate],
TaxpayerID
)
VALUES
(
@pid,
@txYr,
@ptype,
@regno,
@city,
@cnty,
@state,
@mfgMake,
@mfgModel,
@yrBuilt,
@SN,
@dtePurchased,
ISNULL(@aCost,0),
@issues,
@issuedetails,
@hrsbtwn,
@lastsince,
@LasthrOv,
@totHrsOnAifm,
@AvionExtrEq,
@fdate,
@tID
)
end
END