Non arrondissement d'un nombre.

zakaroh Messages postés 42 Date d'inscription mercredi 23 avril 2008 Statut Membre Dernière intervention 23 août 2008 - 14 août 2008 à 17:56
zakaroh Messages postés 42 Date d'inscription mercredi 23 avril 2008 Statut Membre Dernière intervention 23 août 2008 - 15 août 2008 à 14:36
bonjour,
j'ai un probleme; quand je saisie un nombre 12.3 dans textbox, il s'arrondit a 13 je veux que ca reste 12.3 mon code est le suivant:

SqlCommand command = new SqlCommand("INSER INTO [Table_test] [toto], [bobo] VALUEU (@toto @bobo)"');", connection);

command.Parameters.Add(new SqlParameter("@toto", SqlDbType.Decimal));
command.Parameters.Add(new SqlParameter("@bobo", SqlDbType.Decimal));


if (textBox_toto.Text != "")
{
command.Parameters["@toto"].Value = decimal.Parse(textBox_toto.Text, System.Globalization.CultureInfo.InvariantCulture);
}
else command.Parameters["@toto"].Value = System.DBNull.Value;

if (textBox_bobo.Text != "")
{
command.Parameters["@bobo"].Value = decimal.Parse(textBox_bobo.Text, System.Globalization.CultureInfo.InvariantCulture);
}
else command.Parameters["@bobo"].Value = System.DBNull.Value;
command.ExecuteNonQuery();
merci

2 réponses

ikaer Messages postés 42 Date d'inscription lundi 14 janvier 2008 Statut Membre Dernière intervention 23 septembre 2008
15 août 2008 à 10:56
J'ai pas de souci si je convertis le contenu d'une textBox en decimal pour garder les digits.

Par contre si en fait tu utilises des numericUpDown, tu dois changer la precision avec la propriété DecimalPlaces (sinon il arrondit par defaut à un entier)
0
zakaroh Messages postés 42 Date d'inscription mercredi 23 avril 2008 Statut Membre Dernière intervention 23 août 2008 1
15 août 2008 à 14:36
salut,
j'utilse des textbox, je dois changer quoi dans mon code pour que j'arrive a garder les nombre decimal son arrondissement,
merci

zakaroh
0
Rejoignez-nous