Been banging my head on the desk for days over this one...
I have a program that tracks my card collections for me. This pulls information from a SQL database and displays which card I'm looking for and how many of them I own.
This code actually works:
So, what this does is basically checks the database for "CardGame1", searches through Col 8 for the "filter" keyword that I'm looking for (in which "Box" the card was included), and (for now) generates a list in the log of each card in the collection that matches the keyword filter. So, if I have 3 cards that match the keyword I'm looking for and 3 of each card, the log will look like this:
Card A
Card A
Card A
Card B
Card B
Card B
Card C
Card C
Card C
Here's the problem:
I have an IDENTICAL code set that checks all other card games in my collection for the same filter. The database has the same columns as the previous card game, only the table name is different (note "CardGame2" below):
Even though this code is identical and runs through the same procedure as the previous one, I get an error message that reads:
Card D
Card D
Card D
java.lang.IllegalStateException: Couldn't read row 0, col 8 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
Even more frustrating, this code runs perfectly until it is supposed to reach row 1. Cards D,E, and F are in the filter range, with 3 copies of each. It detects the first set of 3 just fine, but then tells me it can't read row 0 (which, by my logic, should be on row 1). Even if it wasn't advancing, it would simply read "Card D" 9 times would it not?
This has boggled me for 3 days. Any help from the experts out there would be greatly appreciated! Happy coding all!
I have a program that tracks my card collections for me. This pulls information from a SQL database and displays which card I'm looking for and how many of them I own.
This code actually works:
B4X:
Dim Cursor1 As Cursor
Dim i As Int
Dim j As Int
Dim Multiply As Int
Cursor1 = SQL1.ExecQuery("SELECT ID, Name, Group1, Group2, Height, Width, Inclusion, Restricted, Box, Front, Back FROM CardGame1")
Cursor1.Position=0
'Scan all cards for pre-set "Filter" string
For i=0 To Cursor1.RowCount-1
Cursor1.Position=i
If Cursor1.GetString2(8)=Filter Then
Multiply=Cursor1.GetInt2(6)
For j=0 To Multiply-1
Log(Cursor1.GetString2(1))
Next
End If
Next
Cursor1.close
So, what this does is basically checks the database for "CardGame1", searches through Col 8 for the "filter" keyword that I'm looking for (in which "Box" the card was included), and (for now) generates a list in the log of each card in the collection that matches the keyword filter. So, if I have 3 cards that match the keyword I'm looking for and 3 of each card, the log will look like this:
Card A
Card A
Card A
Card B
Card B
Card B
Card C
Card C
Card C
Here's the problem:
I have an IDENTICAL code set that checks all other card games in my collection for the same filter. The database has the same columns as the previous card game, only the table name is different (note "CardGame2" below):
B4X:
Dim Cursor1 As Cursor
Dim i As Int
Dim j As Int
Dim Multiply As Int
Cursor1 = SQL1.ExecQuery("SELECT ID, Name, Group1, Group2, Height, Width, Inclusion, Restricted, Box, Front, Back FROM CardGame2")
Cursor1.Position=0
'Scan all cards for pre-set "Filter" string
For i=0 To Cursor1.RowCount-1
Cursor1.Position=i
If Cursor1.GetString2(8)=Filter Then
Multiply=Cursor1.GetInt2(6)
For j=0 To Multiply-1
Log(Cursor1.GetString2(1))
Next
End If
Next
Cursor1.close
Even though this code is identical and runs through the same procedure as the previous one, I get an error message that reads:
Card D
Card D
Card D
java.lang.IllegalStateException: Couldn't read row 0, col 8 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
Even more frustrating, this code runs perfectly until it is supposed to reach row 1. Cards D,E, and F are in the filter range, with 3 copies of each. It detects the first set of 3 just fine, but then tells me it can't read row 0 (which, by my logic, should be on row 1). Even if it wasn't advancing, it would simply read "Card D" 9 times would it not?
This has boggled me for 3 days. Any help from the experts out there would be greatly appreciated! Happy coding all!