Hello,
I have the following code for inserting a decimal value into my ms access database (2007).
I wrote a function the rounds the value in txtPrijsEenheid to the nearest .05
When I enter the value 12,21 in the textbox txtPrijsEenheid the value of the decimal test is 12.2
But the value that is inserted into the table is 122
The type of the database field is decimal(18,2)
What Am I doing wrong here?
I have the following code for inserting a decimal value into my ms access database (2007).
Code:
dim test as decimal = If(Me.txtPrijsEenheid.Text = String.Empty, 0, AfrondenNaar(Me.txtPrijsEenheid.Text, 0.05))
cmdInsert.Parameters.Add("@Prijs", OleDbType.Decimal).Value = testCode:
Public Function AfrondenNaar(ByVal Waarde As Decimal, ByVal Stap As Decimal) As Decimal
Dim D1 As Decimal
D1 = Math.Round(Waarde / Stap)
Return Stap * D1
End FunctionBut the value that is inserted into the table is 122
The type of the database field is decimal(18,2)
What Am I doing wrong here?