Procedure or function has too many arguments specified [modified]
-
Hi everybody I am a beginner and facing the problem in calling a Stored Procedure from within my VB.NET 2005, as below: MY Stored Procedure goes like;
ALTER PROCEDURE ByRoyalty @percentage int, @avgprice float Output AS SELECT @avgprice= AVG(price) FROM titles SELECT au_id FROM titleauthor WHERE titleauthor.royaltyper = @percentage DECLARE @numtitles Int SELECT @numtitles=COUNT(*) FROM titles RETURN @numtitles
My VB code is as below:Dim cmd As New SqlCommand("ByRoyalty", Conxn) With cmd .CommandType = CommandType.StoredProcedure .Parameters.Add("@numtitles", SqlDbType.Int) .Parameters(0).Direction = ParameterDirection.ReturnValue .Parameters.AddWithValue("@percentage", 100) .Parameters(1).Direction = ParameterDirection.Input .Parameters.Add("@avgprice", SqlDbType.Float) .Parameters(2).Direction = ParameterDirection.Output End With Dim dr As SqlDataReader = cmd.ExecuteReader()
Running the above vb code reports the following error: "Procedure or function ByRoyalty has too many arguments specified." Please help -- modified at 8:06 Friday 11th August, 2006 -
Hi everybody I am a beginner and facing the problem in calling a Stored Procedure from within my VB.NET 2005, as below: MY Stored Procedure goes like;
ALTER PROCEDURE ByRoyalty @percentage int, @avgprice float Output AS SELECT @avgprice= AVG(price) FROM titles SELECT au_id FROM titleauthor WHERE titleauthor.royaltyper = @percentage DECLARE @numtitles Int SELECT @numtitles=COUNT(*) FROM titles RETURN @numtitles
My VB code is as below:Dim cmd As New SqlCommand("ByRoyalty", Conxn) With cmd .CommandType = CommandType.StoredProcedure .Parameters.Add("@numtitles", SqlDbType.Int) .Parameters(0).Direction = ParameterDirection.ReturnValue .Parameters.AddWithValue("@percentage", 100) .Parameters(1).Direction = ParameterDirection.Input .Parameters.Add("@avgprice", SqlDbType.Float) .Parameters(2).Direction = ParameterDirection.Output End With Dim dr As SqlDataReader = cmd.ExecuteReader()
Running the above vb code reports the following error: "Procedure or function ByRoyalty has too many arguments specified." Please help -- modified at 8:06 Friday 11th August, 2006numtitles needs to be an input to the procedure: Try:
ALTER PROCEDURE ByRoyalty @percentage int, @avgprice float Output, @numtitles int Output AS SELECT @avgprice= AVG(price) FROM titles SELECT au_id FROM titleauthor WHERE titleauthor.royaltyper = @percentage SELECT @numtitles=COUNT(*) FROM titles RETURN @numtitles
Mike Lasseter
-
numtitles needs to be an input to the procedure: Try:
ALTER PROCEDURE ByRoyalty @percentage int, @avgprice float Output, @numtitles int Output AS SELECT @avgprice= AVG(price) FROM titles SELECT au_id FROM titleauthor WHERE titleauthor.royaltyper = @percentage SELECT @numtitles=COUNT(*) FROM titles RETURN @numtitles
Mike Lasseter
Sorry, it still reports the same error. Any other idea, please!
-
Hi everybody I am a beginner and facing the problem in calling a Stored Procedure from within my VB.NET 2005, as below: MY Stored Procedure goes like;
ALTER PROCEDURE ByRoyalty @percentage int, @avgprice float Output AS SELECT @avgprice= AVG(price) FROM titles SELECT au_id FROM titleauthor WHERE titleauthor.royaltyper = @percentage DECLARE @numtitles Int SELECT @numtitles=COUNT(*) FROM titles RETURN @numtitles
My VB code is as below:Dim cmd As New SqlCommand("ByRoyalty", Conxn) With cmd .CommandType = CommandType.StoredProcedure .Parameters.Add("@numtitles", SqlDbType.Int) .Parameters(0).Direction = ParameterDirection.ReturnValue .Parameters.AddWithValue("@percentage", 100) .Parameters(1).Direction = ParameterDirection.Input .Parameters.Add("@avgprice", SqlDbType.Float) .Parameters(2).Direction = ParameterDirection.Output End With Dim dr As SqlDataReader = cmd.ExecuteReader()
Running the above vb code reports the following error: "Procedure or function ByRoyalty has too many arguments specified." Please help -- modified at 8:06 Friday 11th August, 2006Hi Friend, Can you change the line as follows. .Parameters.Add("@percentage", 100) - I think 'Add' Method is enough here. With Regards, Pandian S
-
Hi Friend, Can you change the line as follows. .Parameters.Add("@percentage", 100) - I think 'Add' Method is enough here. With Regards, Pandian S
THOUSANDS OF PARDONS to all the friends who tried to help. The problem was something different. As a matter of fact, all the changes I was making had been commencing in the LOCAL COPY of my database. For this reason, my changes did not reflect in the result set. I again aplogize everybody. With gread regards.