Procedure has too many arguements specified

C

Ctal

I've got a simple winform app that populates a datagrid on load. There
are some text boxes on the form where users can add, delete or modify
the grid. I'm using a data adapter to fill the grid and update the
database. I've created stored procedures for select, insert, update,
and delete.

When I try to write data back to the database, I get the error
mentioned in the title. I ran a trace with SQL profiler and it appears
my app is sending double the # of params I need. Not sure how this is
happening. Here's my code.

Insert sproc:

ALTER PROCEDURE [dbo].[usp_AddSignCon]
@Account varchar(255) = '',
@ReverseSign char(1) = 'Y',
@ModifiedBy varchar(255) = 'System',
@RuleStatus char(1) = 'Y'

AS
BEGIN
SET NOCOUNT ON;

INSERT INTO dbo.AddSignCon
(Account, ReverseSign, ModifiedBy, RuleStatus)

VALUES
(@Account, @ReverseSign, @ModifiedBy, @RuleStatus)


Method to Update:

public void UpdateDataSetDA(DataSet dataSet, string sourceTable)

{

DA.InsertCommand=new SqlCommand();
DA.InsertCommand.Connection=CN;
DA.InsertCommand.CommandType = CommandType.StoredProcedure;
DA.InsertCommand.CommandText = "dbo.usp_AddSignCon";
DA.InsertCommand.Parameters.Clear();
DA.InsertCommand.Parameters.Add(new
SqlParameter("@Account",
SqlDbType.VarChar, 255, "Account"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@ReverseSign",
SqlDbType.Char, 1, "ReverseSign"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@ModifiedBy",
SqlDbType.VarChar, 255, "ModifiedBy"));
DA.InsertCommand.Parameters.Add(new
SqlParameter("@RuleStatus",
SqlDbType.Char, 1, "RuleStatus"));


//Snipped code that updates and deletes

DA.Update(dataSet.Tables[sourceTable]);
}


It's bombing on the last line and like I saw with profiler, it appears
to be sending the parameters twice. So I'm sending 8 instead of 4.
Here's my sample trace:

exec dbo.usp_AddSignCon
@Account='TestAccount',@ReverseSign='Y'@ModifiedBy='TestUser',@RuleStatus='Y',@Account='TestAccount',@ReverseSign='Y'@ModifiedBy='TestUser',@RuleStatus='Y'

Thanks in advance for any help
 
C

Ctal

Daniel said:
Post your snipped code please....... thanks.

Thank you Daniel !!! I saw where you were headed and sure enough, I
had referenced the InsertCommand in the snipped sections. Wish I had a
nickel for everytime cut/paste has bit me like that :)

I corrected the code and it works fine now. thanks again
 
D

Daniel

lol yep glad you saw it. No worries :)

Ctal said:
Thank you Daniel !!! I saw where you were headed and sure enough, I
had referenced the InsertCommand in the snipped sections. Wish I had a
nickel for everytime cut/paste has bit me like that :)

I corrected the code and it works fine now. thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top