I am getting error when updating records. I am using parameterized update query. below is the code and error.
-------------------------------------------------------------
code
-------------------------------------------------------------
Private Sub btnupdate_Click(sender As Object, e As EventArgs) Handles btnupdate.Click
Try
con.Open()
ss = "UPDATE salary_master set empname=@empname,bsalary=@bsalary,hra=@hra,da=@da,pf=@pf,medamt=@medamt,allowance=@allowance," & _
"others=@others,desig=@desig,remarks=@remarks WHERE empid=@empid"""
com.Parameters.AddWithValue("@empid", txtempid.Text)
com.Parameters.AddWithValue("@empname", txtempname.Text)
com.Parameters.AddWithValue("@desig", txtdesig.Text)
com.Parameters.AddWithValue("@bsalary", txtbsalary.Text)
com.Parameters.AddWithValue("@hra", txthra.Text)
com.Parameters.AddWithValue("@da", txtda.Text)
com.Parameters.AddWithValue("@pf", txtpf.Text)
com.Parameters.AddWithValue("@medamt", txtmed.Text)
com.Parameters.AddWithValue("@allowance", txtallow.Text)
com.Parameters.AddWithValue("@others", txtother.Text)
com.Parameters.AddWithValue("@remarks", txtremarks.Text)
com.ExecuteNonQuery()
MsgBox("Record Updated Successfully !", MsgBoxStyle.Information)
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
------------------------------------------------------------------------
error:-
------------------------------------------------------------------------
The variable name '@empid' has already been declared. Variable names must be unique within a query batch or stored procedure.
--------------------------------------------------------------------------