本文介绍了如何将十进制值插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我从后面的代码(c#)发送的天数为float值,表中的天数的数据类型为十进制(2.1),但是当我发送的天数为0.5时,它被保存为1数据库如何进行
Hi
I am sending the value for number of days as float from the code behind(c#) and the datatype for number of days in the table is decimal(2.1) but when i send 0.5 as the number of days it is getting saved as 1 into the database how to proceed
推荐答案
MySqlCommand cmd = new MySqlCommand("INSERT INTO youTable (numberOfDays) VALUE (@numberOfDays)", yourConnection);
cmd.Parameters.AddWithValue("@numberOfDays", numberOfDays);
假定numberOfDays是您的浮点值.
This assumes that numberOfDays is your float value.
这篇关于如何将十进制值插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!