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
    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...")
    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 by Ezzaral: Do not write in all uppercase or use "leet", "txt" or "chatroom" speak.. Do use clear and relevant titles for new threads.

Votes + Comments
Stop posting as two different users
5 Years
Discussion Span
Last Post by Reverend Jim

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

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.


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

Edited 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 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.