Sub btnImport_Click
DoEvents
pgbMain.Progress = 0
pgbMain.Visible = True
List1.Initialize
List1 = StringUtils1.LoadCSV(File.DirAssets, "test3.csv", ";")
SQL1.Initialize(File.DirRootExternal, "test1.db", True)
SQL1.ExecNonQuery("DROP TABLE IF EXISTS table1")
SQL1.ExecNonQuery("CREATE TABLE table1 (col1 TEXT, col2 TEXT, col3 TEXT, col4 TEXT, col5 TEXT, col6 TEXT, col7 TEXT, col8 TEXT, col9 TEXT, col10 TEXT, col11 TEXT, col12 TEXT, col13 REAL, col14 TEXT)")
SQL1.BeginTransaction
Try
For I = 0 To List1.Size-1
Dim ColumnContent() As String
Dim Amount As String
Dim Value As Double
ColumnContent = List1.Get(I)
If ColumnContent(10) = "Material" OR ColumnContent(10) = "Result" OR ColumnContent(10) = "#" Then
Else
Amount = ColumnContent(12)
Amount = Amount.SubString2(0, Amount.Length - 4) ' removes EUR
Amount = Amount.Replace(".", "") ' removes the '.'
Amount = Amount.Replace(",", ".") ' replaces ',' by '.'
Value = Amount
SQL1.ExecNonQuery2("INSERT INTO table1 VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object (ColumnContent(0), ColumnContent(1), ColumnContent(2), ColumnContent(3), ColumnContent(4), ColumnContent(5), ColumnContent(6), ColumnContent(7), ColumnContent(8), ColumnContent(9), ColumnContent(10), ColumnContent(11), Value, ColumnContent(13)))
End If
DoEvents
pgbMain.Progress = I * 100 / List1.Size-1
Next
DoEvents
pgbMain.Progress = 100
SQL1.TransactionSuccessful
pgbMain.Visible = False
Catch
Log(LastException.Message)
End Try
SQL1.EndTransaction
End Sub