0

テーブルに float 値を追加しようとしています。Sqlite update コマンドの使用

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

したがって、ここでは、行の値が null ではなく、浮動小数点数であることを確認しています。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

ありがとうサン

4

1 に答える 1

0

float の代わりに Decimal を使用して問題を解決しました

于 2012-05-29T22:44:22.970 に答える