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
VulpesPosted Feb 21, 2012, 4:43 AM
I'd try explicitly converting to currency in the query itself.
So, change this line:
com.Parameters.Add("@VkpopustbezDDV", OleDbType.Currency).Value = dvalue;
to this:
com.Parameters.Add("@VkpopustbezDDV", OleDbType.Double).Value = (double)dvalue;
and then, within your query, replace @VkpopustbezDDV with:
CCur(@VkpopustbezDDV)
NelPosted Feb 21, 2012, 6:21 AM