0

我正在尝试向表中添加一些浮点值。使用 Sqlite 更新命令

   float Cu= row.Cells["Cu"].Value != null && float.TryParse(row.Cells["Cu"].Value.ToString(), out Cu) ? Cu: 0;

所以在这里我确保行中的值不为空并且也是浮动的。如果为真,则插入该值,否则插入 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

谢谢你孙

4

1 回答 1

0

我使用十进制而不是浮点数,它解决了问题

于 2012-05-29T22:44:22.970 回答