Error where there was none

Smee

Well-Known Member
Licensed User
Longtime User
Very strange.

I am getting an error with this code

B4X:
    SQLConn.ExecNonQuery("DROP TABLE IF EXISTS Pictures")
    SQLConn.ExecNonQuery("CREATE TABLE Pictures (Picture TEXT)")

Dim su As StringUtils
Dim Table As List
Dim Table1 As List
Dim Cells() As String ' allows individual items
Dim m As Map
Dim i As Int

Table = su.LoadCSV(File.DirAssets, "Pictures.csv", ",")
Table1.Initialize
For i = 0 To Table.Size - 1
 Cells = Table.Get(i)
 m.Initialize
 m.Put("Picture", Cells(0))
 Log(Cells(0))
 Table1.Add(m)
Next

DBUtils.InsertMaps(SQLConn,"Pictures", Table1)

Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:anywheresoftware.b4a.agraham.pageturnviewdemo
** Activity (main) Create, isFirst = true **
slide1.jpg
slide2.jpg
slide3.jpg
slide4.jpg
slide5.jpg
slide6.jpg
slide7.jpg
slide8.jpg
slide9.jpg
slide10.jpg
slide11.jpg
slide12.jpg
slide13.jpg
slide14.jpg
InsertMaps (first query out of 14): INSERT INTO [Pictures] ([Picture]) VALUES (?)
** Activity (main) Resume **
main_getfilename (java line: 366)
android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 14
at android.database.AbstractCursor.checkPosition

etc
etc

i have checked the file and what is logged is what is in the file
i have re-booted machine uninstalled etc but i cannot work out what is going on
:confused::confused:

EDIT:

BUGGER ....
I thought this line was throwing me an error
B4X:
InsertMaps (first query out of 14): INSERT INTO [Pictures] ([Picture]) VALUES (?)

but it is not. in this case i had initialised a counter incorrectly
 
Last edited:

Kevin

Well-Known Member
Licensed User
Longtime User
I'm not positive (and I'm at work so I can't test this) but perhaps

For i = 0 To Table.Size - 1

should be

For i = 0 To (Table.Size - 1)



Worth a shot anyway.
 
Upvote 0
Top