Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27514

VS 2010 Problem inserting decimal into access database

$
0
0
Hello,

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 = test

I wrote a function the rounds the value in txtPrijsEenheid to the nearest .05
Code:

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 Function

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?

Viewing all articles
Browse latest Browse all 27514

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>