gpt4 book ai didi

c# - 字符串 "0.080"加倍使 80.00

转载 作者:可可西里 更新时间:2023-11-01 07:45:50 25 4
gpt4 key购买 nike

<分区>

我在 c# 中遇到这个问题,我想将一个字符串转换为 double。

textBoxKostOnderhoud.Text = "0.08";

kost.OnderhoudKost = double.Parse(textBoxKostOnderhoud.Text);

这使我的数据库中出现了 80.00,但我不知道为什么。这个问题有解决办法吗?

这就是我将值添加到数据库 (mysql) 的方式

public bool insert(Kost kost)
{
string query = "INSERT INTO kost (wagenId, onderhoudKost, tolKost, bedrijfsVerzekering, autoVerzekering, ladingVerzekering, wegenBelasting, eurovignet, accountantKost, telefoonKost, documentenEnVergunningen, onvoorzien, overige, andere) VALUES('" + kost.WagenId + "', '" + kost.OnderhoudKost + "', '" + kost.TolKost + "', '" + kost.BedrijfsVerzekering + "', '" + kost.AutoVerzekering + "', '" + kost.LadingVerzekering + "', '" + kost.WegenBelasting + "', '" + kost.Eurovignet + "', '" + kost.AccountantKost + "', '" + kost.TelefoonKost + "', '" + kost.DocumentenEnVergunningen + "', '" + kost.Onvoorzien + "', '" + kost.Overige + "', '" + kost.Andere + "')";

if (this.OpenConnection())
{
//Create Command
MySqlCommand cmd = new MySqlCommand(query, connection);
//Create a data reader and Execute the command
cmd.ExecuteReader();

//close Connection
this.CloseConnection();

return true;
}
else
{
return false;
}
}

数据库

CREATE TABLE IF NOT EXISTS `kost` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`wagenId` int(11) NOT NULL,
`onderhoudKost` double(10,2) NOT NULL,
`tolKost` double(10,2) NOT NULL,
`bedrijfsVerzekering` double(10,2) NOT NULL,
`autoVerzekering` double(10,2) NOT NULL,
`ladingVerzekering` double(10,2) NOT NULL,
`wegenBelasting` double(10,2) NOT NULL,
`eurovignet` double(10,2) NOT NULL,
`accountantKost` double(10,2) NOT NULL,
`telefoonKost` double(10,2) NOT NULL,
`documentenEnVergunningen` double(10,2) NOT NULL,
`onvoorzien` double(10,2) NOT NULL,
`overige` double(10,2) NOT NULL,
`andere` double(10,2) NOT NULL,
PRIMARY KEY (`id`),
KEY `wagenId` (`wagenId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=64 ;

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com