Dbase question

parijs

Active Member
Licensed User
Longtime User
Last question for this year ;)

In my db I use districts
I wants to show a Listview with only the select districts
But also need other variable off this row
There are 270 districts in the dB, but I will have about 30 left over at the end, after filtering.
I know that favot(32), mapc(32 is not enough in my case.
This is my code and I can not find where the error is.

Dim favot(32) As String
Dim mapc(32) As String
main.aron = "Reuilly"
Dim cur As Cursor


Dim intCount As Int
SQL.Initialize(File.DirRootExternal, "VisitParijs/visit.db", False)
intCount = SQL.ExecQuerySingleResult("SELECT count(*) FROM visit")

cur = SQL.ExecQuery2("SELECT MapNaam, Regelonder, pic, wijk, keuze FROM visit WHERE wijk = ?", Array As String(main.aron))
For i = 0 To intCount -1
cur.Position = i

mapc(i) = cur.GetString("MapNaam")
main.regelonder = cur.GetString("Regelonder")
favot(i) = cur.GetString("keuze")
wijk = cur.GetString("wijk")
main.pic = cur.GetString("pic")

Bitmap1.Initialize(File.DirAssets, main.pic)
ListView1.AddTwoLinesAndBitmap(mapc(i), main.regelonder, Bitmap1)

Next

:signOops:
 

bees

Member
Licensed User
Longtime User
This is my code and I can not find where the error is.

You did not say what the error is.
You might get problems with your for/next loop
Your intCount will most likely be larger than the number of rows
in your cursor, so I do not see why you need the intCounter.

Maybe this helps
B4X:
Dim nRows as Int
Dim nPos   as Int
Dim oRst   as Cursor
 
main.aron = "Reuilly"
oRst = SQL.ExecQuery2("SELECT MapNaam, Regelonder, pic, wijk, keuze FROM visit WHERE wijk = ?", Array As String(main.aron))
nRows = oRst
If nRows < 1 then Return
 
Dim favot(nRows) As String
Dim mapc(nRows) As String
 
nRows = nRows - 1
For nPos = 0 To nRows
  oRst.Position     = i
  mapc(nPos)       = oRst.GetString("MapNaam") 
  main.regelonder = oRst.GetString("Regelonder")
  favot(nPos)       = oRst.GetString("keuze")
  wijk                 = oRst.GetString("wijk") 
  main.pic           = oRst.GetString("pic") 
 
  Bitmap1.Initialize(File.DirAssets, main.pic)
        ListView1.AddTwoLinesAndBitmap(mapc(nPos), main.regelonder, Bitmap1) 
 
Next

Groeten,

Stephen
 
Last edited:
Upvote 0

parijs

Active Member
Licensed User
Longtime User
Hi Bees,

With your code I get the error:

NumberFormatException:(SQLiteCursorandroid.database.sqlite.SQLite@40560ca0

With my code I get the error:

CursorIndexOutBoundsException:Index 11 reguested, with a size of 11

(there are 11 Reuilly's in my dB)
 
Upvote 0
Top