2
Answers

Problem when saving currency type in access database

Nel

Nel

12y
2.1k
1
Hello,I insert currency type balue in my access database. When I press the insert button in the textbox I can see the correct value, but when I check it in the database it is an Integer, i.e. not the correct value which I inserted and which I saw in the textbox, after pressing the insert button.
Here is my code:

if (Convert.ToInt32(textBox10.Text) >= 12)
            {

                if (Convert.ToInt32(textBox4.Text) <= 20 && Convert.ToInt32(textBox4.Text) > 1)
                {
                    label34.Text = (Decimal.Parse(textBox7.Text) * 5 / 100).ToString();
                }
                else if (Convert.ToInt32(textBox4.Text) <= 40 && Convert.ToInt32(textBox4.Text) > 21)
                {
                    label34.Text = (Decimal.Parse(textBox7.Text) * 15 / 100).ToString();
                }
                else if (Convert.ToInt32(textBox4.Text) <= 70 && Convert.ToInt32(textBox4.Text) > 41)
                {
                    label34.Text = (Decimal.Parse(textBox7.Text) * 25 / 100).ToString();
                }
                else if (Convert.ToInt32(textBox4.Text) > 71)
                {
                    label34.Text = (Decimal.Parse(textBox7.Text) * 50 / 100).ToString();
                }

            }
            else
            {
                int popust = 0;
                label34.Text = popust.ToString();
            }

            dvalue = 0;
            decimal.TryParse(label34.Text, out dvalue);
            com.Parameters.Add("@VkpopustbezDDV", OleDbType.Currency).Value = dvalue;


Can anybody help me please what is my problem? Why it is changed and not inserted like currency but int type value in the access database?

Thank you in advance


Answers (2)