我找不到任何解决方案,如何将float在C#中保存到mySQL。它保存只是整数。如果我的浮子是2.5,并且我将其保存到桌子中,那么它比有2。
我将类型更改为加倍,但是我得到了相同的结果。有人可以帮我吗?
您可以使用
的类型DECIMAL
一些信息您可以获得此
这是我的sql命令:
using (MySqlConnection connection = new MySqlConnection(sqlConnString.GetConnectionString(true)))
{
connection.Open();
string SQLString = @"INSERT INTO account_components
(accountID,shapeMother,shapeFather,skinMother,skinFather,shapeMix,skinMix,
eyeColor,eyeBrows,lipstick,lipstickColor,beard,beardColor,
hair,hairColor) VALUES
('" + _acc.Id + "'," +
"'" + _acc.Character.ShapeMother + "'," +
"'" + _acc.Character.ShapeFather + "'," +
"'" + _acc.Character.SkinMother + "'," +
"'" + _acc.Character.SkinFather + "'," +
"'@ShapeMix'," +
"'@SkinMix'," +
"'" + _acc.Character.EyeColor + "'," +
"'" + _acc.Character.EyeBrows + "'," +
"'" + _acc.Character.Lipstick + "'," +
"'" + _acc.Character.LipstickColor + "'," +
"'" + _acc.Character.Beard + "'," +
"'" + _acc.Character.BeardColor + "'," +
"'" + _acc.Character.Hair + "'," +
"'" + _acc.Character.HairColor + "')";
using (MySqlCommand cmd = new MySqlCommand(SQLString, connection))
{
cmd.Parameters.Add("ShapeMix", MySqlDbType.Float).Value = 0.5f; //_acc.Character.ShapeMix;
cmd.Parameters.Add("SkinMix", MySqlDbType.Float).Value = 0.5f; //_acc.Character.SkinMix;
cmd.ExecuteNonQuery();
}
} //connection closed and disposed here
}
这是我的数据库:数据库描述