Error occured: Procedure .. has too many argument specified

I have an issue that when i Update the record there is error "Error occured: Procedure .. has too many argument specified". It is my Store procedure

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


ALTER Procedure [dbo].[web_usp_empData_Update]
    @id bigint,
    @Code nvarchar(10),
    @Name nvarchar(50),
    @Address nvarchar(150),
    @Tel nvarchar(20),
    @HP nvarchar(20),
    @email nvarchar(50),
    @NRIC nvarchar(20),
    @Jobtitle nvarchar(50),
    @Dept nvarchar(20)
As
Begin
    Update empData
    Set
        [Code] = @Code,
        [Name] = @Name,
        [Address] = @Address,
        [Tel] = @Tel,
        [HP] = @HP,
        [email] = @email,
        [NRIC] = @NRIC,
        [Jobtitle] = @Jobtitle,
        [Dept] = @Dept
    Where       
        [id] = @id

End

My update code

 cmd.Connection = conn
    cmd.CommandText = ("web_usp_empData_Update")
    cmd.Parameters.Add(New SqlParameter("@id", Session("empID")))
    cmd.CommandType = CommandType.StoredProcedure
    Try

        cmd.Parameters.AddWithValue("@Code", Me.txtCode.Text)
        cmd.Parameters.AddWithValue("@Name", UCase(Me.txtName.Text))
        cmd.Parameters.AddWithValue("@Address", Me.txtAddress.Text)
        cmd.Parameters.AddWithValue("@Tel", Me.txtTel.Text)
        cmd.Parameters.AddWithValue("@Hp", Me.txtHP.Text)
        cmd.Parameters.AddWithValue("@email", Me.txtEmail.Text)
        cmd.Parameters.AddWithValue("@Nric", Me.txtNRIC.Text)
        cmd.Parameters.AddWithValue("@Jobtitle", Me.cboJobTitle.SelectedValue)
        cmd.Parameters.AddWithValue("@Dept", Me.cboDepartment.SelectedValue)

        conn.Open()
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()
        Response.Redirect("empVIEW.aspx")
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert", "alert('Updated!');", True)

    Catch ex As Exception
        ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Message", "alert('Error occured : " & ex.Message.ToString() & "');", True)
    Finally
        cmd.Dispose()
        conn.Close()
    End Try
Member Avatar for LastMitch

I have an issue that when i Update the record there is error "Error occured: Procedure .. has too many argument specified". It is my Store procedure

@Maideen

Did you type this code or copy & paste the code?

The error look like you mistype a word.

Please double check the spelling from a your table to your code.

Then you will see what I am talking about.

hi
I have added cmd=new sqlcommand. Now there is no error. But could not updated
do you have any idea?
Pls

Member Avatar for LastMitch

do you have any idea?

@Maideen

did you read what I wrote?

Please look at line 13 on your update code.

cmd.Parameters.AddWithValue("@Nric", Me.txtNRIC.Text)

Explain to me how does it look on your database?

@NRIC nvarchar(20),

Replace this code with yours: I think it should work

cmd.Connection = conn        
    cmd.CommandType = CommandType.StoredProcedure
    cmd.CommandText = ("web_usp_empData_Update")
    Try
        cmd.Parameters.AddWithValue("@id", Convert.ToInt64(Session("empID")))
        cmd.Parameters.AddWithValue("@Code", Me.txtCode.Text)
        cmd.Parameters.AddWithValue("@Name", UCase(Me.txtName.Text))
        cmd.Parameters.AddWithValue("@Address", Me.txtAddress.Text)
        cmd.Parameters.AddWithValue("@Tel", Me.txtTel.Text)
        cmd.Parameters.AddWithValue("@Hp", Me.txtHP.Text)
        cmd.Parameters.AddWithValue("@email", Me.txtEmail.Text)
        cmd.Parameters.AddWithValue("@Nric", Me.txtNRIC.Text)
        cmd.Parameters.AddWithValue("@Jobtitle", Me.cboJobTitle.SelectedValue)
        cmd.Parameters.AddWithValue("@Dept", Me.cboDepartment.SelectedValue)
        conn.Open()
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()
        Response.Redirect("empVIEW.aspx")
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert", "alert('Updated!');", True)
    Catch ex As Exception
        ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Message", "alert('Error occured : " & ex.Message.ToString() & "');", True)
    Finally
        cmd.Dispose()
        conn.Close()
    End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.