Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Procedure or function has too many arguments specified [modified]

Procedure or function has too many arguments specified [modified]

Scheduled Pinned Locked Moved Database
helpcsharpdatabaselearning
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    R A Abbasi
    wrote on last edited by
    #1

    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

    M M 2 Replies Last reply
    0
    • R R A Abbasi

      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

      M Offline
      M Offline
      mr_lasseter
      wrote on last edited by
      #2

      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

      R 1 Reply Last reply
      0
      • M mr_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

        R Offline
        R Offline
        R A Abbasi
        wrote on last edited by
        #3

        Sorry, it still reports the same error. Any other idea, please!

        1 Reply Last reply
        0
        • R R A Abbasi

          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

          M Offline
          M Offline
          Member_3269611
          wrote on last edited by
          #4

          Hi Friend, Can you change the line as follows. .Parameters.Add("@percentage", 100) - I think 'Add' Method is enough here. With Regards, Pandian S

          R 1 Reply Last reply
          0
          • M Member_3269611

            Hi Friend, Can you change the line as follows. .Parameters.Add("@percentage", 100) - I think 'Add' Method is enough here. With Regards, Pandian S

            R Offline
            R Offline
            R A Abbasi
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups