Android Question problem with map

3394509365

Active Member
Licensed User
Longtime User
Help in the code below I have a problem in line Cursor3.position = mapid

Using a map to derive the 'ID of a field in a table but does not seem to be MapID declared int int fact, if instead of a fixed number MapID put it all works but if I use the variable does not work. Yet in label1 see it as a number.

???



B4X:
Sub SongACaso(EntryIndex2 AsInt) ' il db normaleDim Cursor3 AsCursorDim Titolo AsStringDim MapTitolo AsStringDim i,MapID AsInt'If IDList.Size = 0 Then 'check if the database is empty
' Return 'if yes leave the routine
'End If

Titolo = spnRepertorio.SelectedItem

Cursor3 = SQL1.ExecQuery("SELECT * FROM [" & TblSpin & "] WHERE [" & GestioneTbl.ColNames(2) & "] = Titolo")

For i=0To Mappa.Size-1

MapTitolo=Mappa.GetValueAt(i)
MapID=Mappa.GetKeyAt(i)
If MapTitolo=Titolo Then
Cursor3.position=MapIDExitEndIfNext

Cursor3.position=MapID

Label1.Text=MapID & "" & MapTitolo& " = " & Titolo

TxtId.Text = Cursor3.GetString(GestioneTbl.ColNames(0))
TxtProg.Text = Cursor3.GetString(GestioneTbl.ColNames(1)) 'read the FirstName columnTxtTitolo.Text = Cursor3.GetString(GestioneTbl.ColNames(2)) 'read the LasstName column
Cursor3.Close 'close the cursor, we don't it anymoreEnd Sub
 

klaus

Expert
Licensed User
Longtime User
This looks strange to me:
B4X:
Cursor3 = SQL1.ExecQuery("SELECT * FROM [" & TblSpin & "] WHERE [" & GestioneTbl.ColNames(2) & "] = Titolo")
Shouldn't it be:
B4X:
Cursor3 = SQL1.ExecQuery("SELECT * FROM [" & TblSpin & "] WHERE [" & GestioneTbl.ColNames(2) & "] = '" & Titolo & "'")
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
on a side note .. this is the first time I have seen square brackets ' [ ] ' used in a SQL statement.
is there any significant reason or just an optional use to compartmentalize a statement.

Thanks
 
Upvote 0
Top