Help me to solve this problem
Conversion from string "LastName" to type 'Double' is not valid.

    Private Sub ButtonAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
    Try
    Call OpenConnection()

    With OleDa
    .UpdateCommand = New OleDb.OleDbCommand()
    .UpdateCommand.CommandText = "UPDATE [INVENTRY] SET [ItemCode] = @ItemCode , [ItemName] = @ItemName , [QTY] = @QTY , [SalePrice] = @SalePrice , [PurchasePrice] = @PurchasePrice WHERE (EmployeeID = ?)"
    .UpdateCommand.Connection = OleCn
    .UpdateCommand.Parameters.Add("@ItemCode", OleDb.OleDbType.VarWChar, 50, "ItemCode").Value = ListView1.Items(0).Text
    .UpdateCommand.Parameters.Add("@ItemName", OleDb.OleDbType.VarWChar, 50, "ItemName").Value = ListView1.Items(0).SubItems(2).Text
    .UpdateCommand.Parameters.Add("@QTY", OleDb.OleDbType.VarWChar, 50, "QTY").Value = "QTY" - ListView1.Items(0).SubItems(3).Text

    End With
    Call CloseConnection()
    MsgBox("Record(s) has been Updated...", MsgBoxStyle.Information, "Record(s) Updated...")
    Me.Close()
    Catch ex As Exception
    MsgBox("Unable to update record(s), Employee ID already exist, please enter another Employee ID...", MsgBoxStyle.Exclamation, "Attention...")
    MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error...")
    Call CloseConnection()
    End Try
    End Sub

Edited 4 Years Ago by Ezzaral: Do not write in all uppercase or use "leet", "txt" or "chatroom" speak.. Do use clear and relevant titles for new threads.

Comments
Stop posting as two different users

After looking at your code, I do not think that you are receiving this error from this chunk of code.

Possibility
One of your substrings from the listviewitem is a string where you are trying to store Quantity.

Can you please give an example of your data.

OR

Can you please insert a breakpoint and copy the chunk of code that is throwing the error?

Edited 4 Years Ago by Begginnerdev

I think you should decide if you are going to post as hhm_pro992 or mh.cool992. Don't post as both and don't post the same code as both.

This article has been dead for over six months. Start a new discussion instead.