SQlite 更新添加一些
本文关键字:添加 更新 SQlite | 更新日期: 2023-09-27 18:35:45
我正在尝试向表中添加一些浮点值。使用 Sqlite 更新命令
float Cu= row.Cells["Cu"].Value != null && float.TryParse(row.Cells["Cu"].Value.ToString(), out Cu) ? Cu: 0;
所以在这里我确保行中的值不为空并且也是浮动的。如果为 true,则插入值,否则插入 0。
Sqlite Update command
insCmdVesselData.Parameters.AddWithValue("@Copper",Cu);
public string SQL_updateVesselData = @"UPDATE
[VesselData]
SET
[Copper]=@Copper,
[Nickel]=@Nickel,
[Phosphorous]=@Phosphorous,
[Silicon]=@Silicon,
[Manganese]=@Manganese,
where
[PlantId] = @PlantId and FileId= @FileId
Here Copper,Nickel is a Numeric in the Database.
Suppose my value of Cu=0.07, during this update, it is adding a number 0.0700000002980232. it the value is 0.5, it updates with 0.529999971389771. Not sure y its adding all these garbage at the end
谢谢太阳
我没有使用浮点数,而是使用了十进制,它解决了这个问题