I am writing a database and need to post a value in a lable to a sql field.
the sql datatype is set to money.

when posting i have

CMD.Parameters.addwithValue("@Claim", LBCLAIM.text)

when posting i gett an error

cannot convert a char vaule to money. the char vaule has incorrect syntax.

please help

Member Avatar


You should be able to cast it to a double or decimal

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim Connection As New SqlServerCe.SqlCeConnection("Data Source=|DataDirectory|\Database1.sdf")
    Dim Command As New SqlServerCe.SqlCeCommand With {.Connection = Connection}

    Command.CommandText = "Insert Into Table1 (MoneyColumn) values(@MoneyColumn)"

    Command.Parameters.AddWithValue("@MoneyColumn", CDbl("$45.56"))

End Sub