title: updating using sql parameters in vb.net
body: <p>my code returns error saying</p>
  
  <blockquote>
    <p>violation of PRIMARY KEY constraint 'PK_tblOfficeEquipmentProfile'. Cannot insert duplicate key in object 'tblOfficeEquipmentProfile'. </p>
  </blockquote>
  
  <p>This is my code:  </p>
  
  <pre><code>Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
      Dim sqlconn As New SqlClient.SqlConnection
      sqlconn.ConnectionString = "server = SKPI-APPS1;" &amp; _
      "Database = EOEMS;integrated security=true"
  
      Dim myCommand As SqlCommand
  
  
      'parametrized update sql command
      Try
          sqlconn.Open()
  
          myCommand = New SqlCommand("UPDATE tblOfficeEquipmentProfile SET OE_Category = @OE_Category, OE_SubCategory = @OE_SubCategory, OE_ID = @OE_ID, OE_Name = @OE_Name, OE_User = @OE_User, OE_Brand = @OE_Brand, OE_Model =@OE_Model, OE_Specs =@OE_Specs, OE_SerialNo =@OE_SerialNo, OE_PropertyNo = @OE_PropertyNo, OE_MacAddress = @OE_MacAddress, OE_Static_IP = @OE_Static_IP, OE_Vendor = @OE_Vendor, OE_PurchaseDate =@OE_PurchaseDate, OE_WarrantyInclusiveYear=@OE_WarrantyInclusiveYear, OE_WarrantyStatus=@OE_WarrantyStatus,OE_Status=@OE_Status,OE_Dept_Code=@OE_Dept_Code,OE_Location_Code=@OE_Location_Code,OE_Remarks=@OE_Remarks", sqlconn)
          myCommand.Parameters.Add("@OE_Category", cmbCategory.Text)
          myCommand.Parameters.Add("@OE_SubCategory", cmbSubCategory.Text)
          myCommand.Parameters.Add("@OE_ID", txtOEID.Text)
          myCommand.Parameters.Add("@OE_Name", txtName.Text)
          myCommand.Parameters.Add("@OE_User", txtUser.Text)
          myCommand.Parameters.Add("@OE_Brand", cmbBrand.Text)
          myCommand.Parameters.Add("@OE_Model", cmbModel.Text)
          myCommand.Parameters.Add("@OE_Specs", txtSpecs.Text)
          myCommand.Parameters.Add("@OE_SerialNo", txtSerialNo.Text)
          myCommand.Parameters.Add("@OE_PropertyNo", txtPropertyNo.Text)
          myCommand.Parameters.Add("@OE_MacAddress", txtMacAddress.Text)
          myCommand.Parameters.Add("@OE_Static_IP", txtStaticIp.Text)
          myCommand.Parameters.Add("@OE_Vendor", cmbVendor.Text)
          myCommand.Parameters.Add("@OE_PurchaseDate", txtPurchaseDate.Text)
          myCommand.Parameters.Add("@OE_WarrantyInclusiveYear", cmbWarrantyInclusiveYear.Text)
          myCommand.Parameters.Add("@OE_WarrantyStatus", txtWarrantyStatus.Text)
          myCommand.Parameters.Add("@OE_Status", txtStatus.Text)
          myCommand.Parameters.Add("@OE_Dept_Code", cmbDeptCode.Text)
          myCommand.Parameters.Add("@OE_Location_Code", cmbLocationCode.Text)
          myCommand.Parameters.Add("@OE_Remarks", cmbRemarks.Text)
  
          myCommand.ExecuteNonQuery()
      Catch ex As Exception
          MsgBox(ex.Message)
          MsgBox("Successfully Updated Records")
      End Try
  End Sub
  </code></pre>