I'm running the following code. It still doesn't work I get
StringIndexOutofboundsException:length=124;regionstart=121;regionlength=122
Sub Button1_Click
Dim su As StringUtils
Dim Table As List
Dim SQL As SQL
Dim never As String
Dim sql1 As SQL
Dim txt As String
Dim found As Boolean
' Initialize database.
SQL.Initialize(File.DirRootExternal, "AssetsManager.db", True)
' Initialize table.
Table.Initialize
now = DateTime.now
Dim DateNow, TimeNow As EditText
DateNow.initialize(0)
DateNow.Text= DateTime.Date(DateTime.Now)
' Work will be used to create unique primary key.
work = now
' only run this bit when resetting database.
If never = "x" Then
DBUtils.DropTable(SQL, "prices")
Dim m As Map
m.Initialize
m.Put("Code",DBUtils.DB_TEXT)
m.Put("Description", DBUtils.DB_TEXT)
m.Put("Units", DBUtils.DB_INTEGER)
m.Put("Price", DBUtils.DB_INTEGER)
m.Put("Value", DBUtils.DB_INTEGER)
m.Put("Date", DBUtils.DB_INTEGER)
m.Put("Pkey", DBUtils.DB_integer)
DBUtils.CreateTable(SQL, "prices", m, "pkey")
End If
Log(File.Dirrootexternal)
' Load Prices file into accessible file. CSV file must be in the same location as the database.
' If I run this routine it doesn't work.
Table = su.LoadCSV(File.Dirrootexternal, "portfolio-summary.csv", ",")
' If I run this routine it does work.
' Table = su.LoadCSV(File.DirAssets, "portfolio-summary.csv", ",")
key = now
' Move the data into a map.
Dim Table2 As List
Dim Items() As String
Table2.Initialize
For i = 5 To 13
Items = Table.Get(i)
Dim m As Map
m.Initialize
m.Put("Code", Items(0))
m.Put("Description", Items(1))
m.Put("Units", Items(2))
m.Put("Price", Items(3))
m.Put("Value", Items(4))
m.put("Date", DateNow.text)
work = work + 1
m.Put("pkey", work)
Table2.Add(m)
Next
' Write map to database.
DBUtils.InsertMaps(SQL, "prices", Table2)
End Sub