2012-05-29 38 views
0

我想將一些浮點值添加到表中。 使用SQLite update命令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][email protected], 
    [Nickel][email protected], 
    [Phosphorous][email protected], 
    [Silicon][email protected], 
[Manganese][email protected], 

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 

感謝ü 孫

回答

0

取而代之的是浮動的,我使用的小數,它解決了這個問題