0

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
3
Contributors
4
Replies
14
Views
4 Years
Discussion Span
Last Post by harsh9
0

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.

Edited by LastMitch

0

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

0

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),

Edited by LastMitch

0

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

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.