none
Procedure or function AddNewTicket has too many arguments specified. RRS feed

  • Question

  • I keep getting this error, I don't know why.  I searched in the forums and it said that you have more parameters than needed.  Here is my code:

      Private Function AddNewTicket() As Int32

            '***************************************************************************
            '* Private Function to add a new mailbox customer to the database
            '* Point to the stored procedure and define the parameters then create the order
            '***************************************************************************

            Dim sqlCmd As New SqlCommand

            '* Set up SQL Command pointing to the add new mailbox customer stored procedure
            sqlCmd.Connection = sqlConMyeBay
            sqlCmd.CommandText = "AddNewTicket"  '* Point to s
            sqlCmd.CommandType = CommandType.StoredProcedure

            '* Set command's transaction property equal to the connection's transaction
            sqlCmd.Transaction = sqlConMyeBay.BeginTransaction

            '* Create input parameters, one for each input parameter in the stored procedure
            With sqlCmd.Parameters
                .Add("@Email", SqlDbType.NVarChar, 50).Value = txtEmail.Text
                .Add("@ItemNumber", SqlDbType.BigInt).Value = txtItemNumber.Text
                .Add("@ItemName", SqlDbType.NVarChar, 50).Value = txtItemName.Text
                .Add("@RefundNote", SqlDbType.NVarChar, 100).Value = txtRefundNote.Text
                .Add("@Resolution", SqlDbType.NVarChar, 50).Value = cboResolution.SelectedItem.ToString
                .Add("DateOpened", SqlDbType.DateTime).Value = txtDate.Text
                .Add("@Description", SqlDbType.NVarChar, 500).Value = txtDescription.Text

                .Add("@TicketID", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
            End With

            '* Execute the stored procedure to create the new order
            sqlCmd.ExecuteNonQuery()

            '* Tell the System to actually change the amount in the SQL DataBase
            sqlCmd.Transaction.Commit()

            Me.lblRMA.Text = "RMA# " & sqlCmd.Parameters("@TicketID").Value & "."
            MessageBox.Show("RMA# " & sqlCmd.Parameters("@TicketID").Value & ".", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End Function

        Private Sub btnAddTicket_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddTicket.Click
            Call AddNewTicket()
        End Sub


    My SP is:

    CREATE PROCEDURE AddNewTicket
    @Email nvarchar(50),
    @ItemNumber bigint,
    @ItemName nvarchar(50),
    @RefundNote nvarchar(100),
    @Resolution nvarchar(50),
    @DateOpened datetime,
    @Description nvarchar(500)
    AS
    DECLARE @TicketID int

    INSERT INTO NewTicket (Email, ItemNumber, ItemName, RefundNote, Resolution, DateOpened, Description)
    VALUES (@Email, @ItemNumber, @ItemName, @RefundNote, @Resolution, @DateOpened, @Description)

    SET @TicketID = @@Identity
    RETURN (@TicketID)
    Friday, April 18, 2008 5:47 AM

Answers

  • When you create parameters in your code do not forget to put @ before DateOpened parameters, like

     

     

    .Add("@DateOpened", SqlDbType.DateTime).Value = txtDate.Text

    Friday, April 18, 2008 9:52 AM
    Moderator

All replies

  • When you create parameters in your code do not forget to put @ before DateOpened parameters, like

     

     

    .Add("@DateOpened", SqlDbType.DateTime).Value = txtDate.Text

    Friday, April 18, 2008 9:52 AM
    Moderator
  • .... I didn't know I could be that blind! Thanks!
    Friday, April 18, 2008 4:39 PM