Error: Too Many Arguments Specified when Inserting Values from ASP.NET to SQL Server

Posted by SidC on Stack Overflow See other posts from Stack Overflow or by SidC
Published on 2010-05-09T20:33:31Z Indexed on 2010/05/09 20:38 UTC
Read the original article Hit count: 199

Good Afternoon All,

I have a wizard control that contains 20 textboxes for part numbers and another 20 for quantities. I want the part numbers and quantities loaded into the following table:

USE [Diel_inventory]
GO
/****** Object:  Table [dbo].[QUOTEDETAILPARTS]    Script Date: 05/09/2010 16:26:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[QUOTEDETAILPARTS](
[QuoteDetailPartID] [int] IDENTITY(1,1) NOT NULL,
[QuoteDetailID] [int] NOT NULL,
[PartNumber] [float] NULL,
[Quantity] [int] NULL,
CONSTRAINT [pkQuoteDetailPartID] PRIMARY KEY CLUSTERED 
(
[QuoteDetailPartID] 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
ALTER TABLE [dbo].[QUOTEDETAILPARTS]  WITH CHECK ADD  CONSTRAINT [fkQuoteDetailID] FOREIGN KEY([QuoteDetailID])
REFERENCES [dbo].[QUOTEDETAIL] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

Here's the snippet from my sproc for this insert:

set @ID=scope_identity()

Insert into dbo.QuoteDetailParts
(QuoteDetailPartID, QuoteDetailID, PartNumber, Quantity)
values (@ID, @QuoteDetailPartID, @PartNumber, @Quantity)

When I run the ASPX page, I receive an error that there are too many arguments specified for my stored procedure. I understand why I'm getting the error, given the above table layout. However, I need help in structuring my insert syntax to look for values in all 20 PartNumber and Quantity field pairs.

Thanks, Sid

© Stack Overflow or respective owner

Related posts about sql-server-2005

Related posts about asp.net-3.5