I need to load a float with 2 demic characters to the database but I couldn't find the solution.
This is my code where I read a string from a text sheet.
row("AmountWithoutVAT") = String.Format("{0:0.00}", line.Substring(114, 8))
UPDATE: This is my complete code ... I read from a file some values to load then in the database ... I read from a file a value like 3050 but I have to write it in the file like 30.50
Private Sub importSpeKM(ByRef pathname As String)
Dim KMasterTable As DataTable
Dim row As DataRow
dsToImport = DB_SQL.OpenDataset("select * from KMaster2 where 1=2", "KMasterID")
KMasterTable = dsToImport.Tables(0)
Dim varcomodo As String = ""
Dim datafile As Date
'Dim filedate As Date
Dim ret As Integer
Dim culture As CultureInfo = Nothing
culture = CultureInfo.CreateSpecificCulture("fr-FR")
Using stream As New StreamReader(pathname)
Dim newline As String = stream.ReadLine
varcomodo = newline.Substring(42, 10)
datafile = CDate(varcomodo)
For Each line As String In File.ReadAllLines(pathname)
If line IsNot Nothing And line.Substring(0, 1) <> "H" And line.Substring(0, 1) <> "F" Then
row = KMasterTable.NewRow()
row("DataKMaster") = datafile
row("ContoAutostrade") = line.Substring(47, 9)
row("TipologiaSupporto") = line.Substring(56, 2)
row("CodiceSupporto") = line.Substring(58, 10)
row("AmountWithoutVAT") = Double.Parse(line.Substring(114, 8), culture)
row("VatAmount") = line.Substring(130, 2)
row("AmountIncludingVAT") = Double.Parse(line.Substring(132, 8), culture)
row("MonthOfCompetence") = line.Substring(178, 7)
row("P_IVA") = line.Substring(202, 12)
row("Targa") = line.Substring(219, 7)
KMasterTable.Rows.Add(row)
End If
Next
ret = DB_SQL.SetDBfromDataset(dsToImport, "KMaster2")
KMasterTable.AcceptChanges()
End Using
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…