-2
我找不到任何解決方案,如何將c#中的float保存到mysql中。它只保存整數。 如果我的浮球是例如2.5,我將它保存到我的表中,比它有一個2.如何將C#float保存到Mysql float?
我改變了類型爲雙倍,但我得到了相同的結果。 有人能幫助我嗎?
我找不到任何解決方案,如何將c#中的float保存到mysql中。它只保存整數。 如果我的浮球是例如2.5,我將它保存到我的表中,比它有一個2.如何將C#float保存到Mysql float?
我改變了類型爲雙倍,但我得到了相同的結果。 有人能幫助我嗎?
這是我的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
}
這是我的數據庫:Database Description
什麼你的查詢看起來像什麼?你在使用參數嗎?顯示一些代碼! – itsme86
列定義是什麼樣的? – mjw