Procedure or function account_register has too many arguments specified lỗi

Checking your browser before accessing crdxeht11der46.xn--b1aff0b8b6b.xn--p1ai.

This process is automatic. Your browser will redirect to your requested content shortly.

Please allow up to 3 seconds...

Bad Bot protection by AntiBot.Cloud

Your IP: 168.138.10.127

I need help again. You see, I am doing a assignment in my last semester and am trying to register Supplier via Stored Procedure.

When i click on the submit btn, it gives me an error saying that Procedure or function has too many arguments specified.

Coding is as below:

VB Code:

  1. Private Sub ImageButton1_Click[ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs] Handles ImageButton1.Click
  2. Dim dbConn As New SqlConnection
  3. dbConn.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["SqlConnection.ConnectionString"]
  4. Dim command As New SqlCommand["spSupplierLogin", dbConn]
  5. command.CommandType = CommandType.StoredProcedure
  6. command.Parameters.Add["@UserID", txtAddUserID.Text.Trim[]]
  7. command.Parameters.Add["@Password", txtAddPassword.Text.Trim[]]
  8. command.Parameters.Add["@Name", txtAddName.Text.Trim[]]
  9. command.Parameters.Add["@Address", txtAddAddress.Text.Trim[]]
  10. command.Parameters.Add["@PostalCode", txtAddPostalCode.Text.Trim[]]
  11. command.Parameters.Add["@Fax", txtAddFax.Text.Trim[]]
  12. command.Parameters.Add["@Tel", txtAddTel.Text.Trim[]]
  13. command.Parameters.Add["@ContactPerson", txtAddContactPerson.Text.Trim[]]
  14. command.Parameters.Add["@Email", txtAddEmail.Text.Trim[]]
  15. command.Parameters.Add["@Remark", txtAddRemark.Text.Trim[]]
  16. command.Parameters.Add["@Status", SqlDbType.Int]
  17. command.Parameters["@Status"].Direction = ParameterDirection.ReturnValue
  18. command.Parameters.Add["@SupplierID", SqlDbType.Int]
  19. command.Parameters["@SupplierID"].Direction = ParameterDirection.Output
  20. dbConn.Open[]
  21. command.ExecuteNonQuery[]
  22. dbConn.Close[]
  23. If command.Parameters.Item["@Status"].Value = -101 Then
  24. lblmEssage.Text = "Member already exists!"
  25. End If
  26. End Sub
  27. End Class

Stored Procedure as below:

Code:

ALTER proc spRegisterSupplier [ @UserId varchar[30], @Password varchar[15], @Name varchar[60], @Address varchar[60], @PostalCode char[6], @Fax char[8], @Tel char[8], @ContactPerson varchar[30], @Email varchar[60], @Remark varchar [1000], @SupplierId int output ] As IF exists [Select userid from Supplier where userid = @UserId] return -101 Insert into Supplier [UserId, Password, Name, Address, PostalCode, Fax, Tel,ContactPerson, Email, Remark] values [@UserId, @Password, @Name, @Address, @PostalCode, @Fax, @Tel,@ContactPerson,@Email, @Remark] SET @SupplierID = @@IDENTITY Return

Any help is appreciated! AkaRoger

Last edited by Aka Roger; Jan 9th, 2007 at 03:01 AM.
Appreciated all helps given. Thanks Guys!
  • Jan 8th, 2007, 11:11 AM

    Re: Procedure or function has too many arguments specified.
    You defined and added 12 parameters but are only declaring 10 parameters in your SP.

    VB/Office Guru� [AKA: Gangsta Yoda� �] I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011 Office Development FAQ [C#, VB.NET, VB 6, VBA] Senior Jedi Software Engineer MCP [VB 6 & .NET], BSEE, CET If a post has helped you then Please Rate it!
    � Reps & Rating Posts � VS.NET on Vista � � Office Primary Interop Assemblies � VB/Office Guru� Word SpellChecker�.NET � VB/Office Guru� Word SpellChecker� VB6 � VB.NET Attributes Ex. � Outlook Global Address List � API Viewer utility � .NET API Viewer Utility � System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

    -
  • Jan 8th, 2007, 05:54 PM

    Re: Procedure or function has too many arguments specified.

    The stored procedure has 10 Input parameters and 1 Output parameter just like the VB code. The code also defines 1 parameter for the sprocs Return Value.

However, I think the Return Value parameter must be the first one added to the parameters collection.

You might want to add a Set NoCount On statement at the beginning of the sproc as well.

- Jan 8th, 2007, 06:23 PM

Re: Procedure or function has too many arguments specified.

No, the VB code has 12 parameters. The @Status parameter is declared and used in vb but not the sp. VB/Office Guru� [AKA: Gangsta Yoda� �] I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006-2011 Office Development FAQ [C#, VB.NET, VB 6, VBA] Senior Jedi Software Engineer MCP [VB 6 & .NET], BSEE, CET If a post has helped you then Please Rate it!
� Reps & Rating Posts � VS.NET on Vista � � Office Primary Interop Assemblies � VB/Office Guru� Word SpellChecker�.NET � VB/Office Guru� Word SpellChecker� VB6 � VB.NET Attributes Ex. � Outlook Global Address List � API Viewer utility � .NET API Viewer Utility � System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Jan 8th, 2007, 08:08 PM

Thread Starter Addicted Member

-

Re: Procedure or function has too many arguments specified.

Hmmmm.. Well you see, there are two output parameters i wish to get in asp.net.

Firstly is the @SupplierID, i want to know the supplier id. The second one would be the @Status to see if any error is given by sp. What i did was following the lecture slides from my school.

Even when i remove the output parameters in asp.net for @Status and @SupplierId, it still gives me the same error.

Regards, Roger Appreciated all helps given. Thanks Guys!

- Jan 8th, 2007, 08:15 PM

Thread Starter Addicted Member

-

Re: Procedure or function has too many arguments specified.

I know that there is something wrong with either my SP or ASP coding

Appreciated all helps given. Thanks Guys!

- Jan 8th, 2007, 09:30 PM

Re: Procedure or function has too many arguments specified.

Move the code to add the Status parameter so that it is first in the list. And then comment it out... you aren't using it... you think you are, but you really aren't. Trust me. The Return that is in your SP doesn't do anything either. Used the way it is here, it's the equivalent to an Exit Sub.

If you insist on "Return"ing something from the SP, that's fine, but return a value. When ever I've needed to capture the ReturnValue of an SP, 1] I've used "@ReturnValue" as the parameter name, and I declare it first, and have never had any problems with it.

-tg

-
  • Jan 8th, 2007, 10:43 PM

    Re: Procedure or function has too many arguments specified.

    When in doubt, create a connection to your database through the IDE. Drag the procedure onto a form, and steal the autogenerated code.

    - Jan 8th, 2007, 11:58 PM

    Thread Starter Addicted Member

    -

    Re: Procedure or function has too many arguments specified.

    But one strange thing is when i insert break point into the command.addparaemeters, it return nothing when it reaches @Address,txtAddAddress.text.trim[] and this is continued till it executes.

I wonder why? Appreciated all helps given. Thanks Guys!

- Jan 9th, 2007, 02:51 AM

Re: Procedure or function has too many arguments specified.

The @Status parameter is declared and used in vb but not the sp. The Parameter.Direction property for @Status is set to ReturnValue. It is populated by the Return statement in the SP. I ran a simple test using the following code against the SQL Server 2000 Northwind.Shippers table [using VWD Express]. Everything worked fine.

Chủ Đề