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 for Unhnd_Exception

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"))

    Connection.Open()
    Command.ExecuteNonQuery()
    Connection.Close()
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.