cannot retrieve record from a table

cirollo

Active Member
Licensed User
Longtime User
Hi! I'm a newbie....

I have a SQL Lite DB with my table 'Impostazioni'
In this table there is only one record, the key is IdConf and the value='EMMECI'
other fields are IdAge, Nominativo, FTPHost, FTPUser, FTPPwd

I would like, when the activity starts, to select this record and put the fields (except the key IdConf, that should remain hidden to the user) in some edittext.
This is my code, but I get always this error:
TxtIdAge.Text=m.Get("IdAge")
java.lang.numberformatexception: IdAge

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim SQL As SQL
SQL = Main.SQL
Dim TxtIdAge As EditText
Dim TxtNominativo As EditText
Dim TxtFtpHost As EditText
Dim TxtFtpUser As EditText
Dim TxtFtpPwd As EditText
Dim RadioButton1 As RadioButton
Dim RadioButton2 As RadioButton
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Impostazioni")

Dim stringa_SQL As String
stringa_SQL="SELECT idAge, Nominativo, " _
& "FTPHost, FTPUser, " _
& "FTPPwd FROM Impostazioni "

Dim m As List
m.Initialize
m = DBUtils.ExecuteMemoryTable(SQL, "" & stringa_SQL, Null, 0)
If m.IsInitialized = False Then
TxtIdAge.Text = ""
TxtNominativo.Text = ""
TxtFtpHost.Text = ""
TxtFtpUser.Text = ""
TxtFtpPwd.Text = ""
Else
TxtIdAge.Text = m.Get("IdAge")
TxtNominativo.Text = m.Get("Nominativo")
TxtFtpHost.Text = m.Get("FTPHost")
TxtFtpUser.Text = m.Get("FTPUser")
TxtFtpPwd.Text = m.Get("FTPPwd")
End If

End Sub
 

cirollo

Active Member
Licensed User
Longtime User
Solved!


SOLVED like this

Dim cur As Cursor
cur = SQL.ExecQuery("" & stringa_SQL)
For i = 0 To cur.RowCount-1
cur.Position = i
m.Put("IdAge",cur.GetString("IdAge"))
m.Put("Nominativo",cur.GetString("Nominativo"))
Next

' m = DBUtils.ExecuteMemoryTable(SQL, "" & stringa_SQL, Null, 0)
If m.IsInitialized = False Then
TxtIdAge.Text = ""
TxtNominativo.Text = ""
'TxtFtpHost.Text = ""
'TxtFtpUser.Text = ""
'TxtFtpPwd.Text = ""
Else
TxtIdAge.Text = m.Get("IdAge")
TxtNominativo.Text = m.Get("Nominativo")
'TxtFtpHost.Text = m.Get("FTPHost")
'TxtFtpUser.Text = m.Get("FTPUser")
'TxtFtpPwd.Text = m.Get("FTPPwd")
End If
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…