B4J Question Error occurred on line: 236 (DBUtils)

oldeast

Active Member
Licensed User
Longtime User
Error occurred on line: 232 (DBUtils)
java.lang.RuntimeException: Object should first be initialized.

I tested the query in SQLite..I saw this once before in b4a but sorry forgot what my error was...
Sub showClassn
'primary classn's

strQuery="SELECT _id [ID#], PrimaryClassText [Primary Classification] FROM PrimaryClass ORDER BY PrimaryClassText ASC;"
'' 'load tableview
DBUtils.ExecuteTableview(SQL1,strQuery,Null,0,tvPrimary)
'secondary classn's
Query="SELECT _id [ID#], SecondClassText [Secondary Classification] FROM SecondClass ORDER BY SecondClassText ASC;"
DBUtils.ExecuteTableview(SQL1,strQuery,Null,0,tvSecond)

'reset to original value
tvSecond.Visible = False
lblSecond.Text="Secondary Classifications"
btnPrimary.Text="Primary Classification"
btnSecond.Text="Secondary Classification"
LblPrimary1.text=""
End Sub
 
Last edited:

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

is the SQL1 Object initialized? Like:

B4X:
  #Region  Project Attributes
  'SQLite driver   
  #AdditionalJar: sqlite-jdbc-3.7.2
  #End Region   


Sub Process_Globals
...   
  Private SQL1 As SQL   
  Private DatabaseFilename As String  = "test.db"
... 

Sub InitSQL
Try 
  SQL1.InitializeSQLite(File.DirApp, DatabaseFilename, True)
Catch
  Log("ERROR init SQLite Database: " & LastException.Message)
End Try
...
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
Thanks Rob,
initSQL does not raise an error.
the app first loads a table view on the main form..no problem, user can open another form to edit the record and update the Classifications.
when loading the classification data into two table views which causes the error.
Commenting out the table view load code, the Classification form loads ok.
I originally had this running in B4A with webviews..


This is the code that works on the main form..
...tableview loads ok


Static code module
#AdditionalJar: sqlite-jdbc-3.7.2
#AdditionalJar:lib/jfxtras-labs-2.2-r5.jar
Sub Process_Globals
Private fx As JFX
Private frmObject As Form
.....etc
...

'open database and show Objects in Tableview
SQL1.InitializeSQLite(DBFileDir, DBFileName,True)

'' 'load tableview
strQuery = "SELECT _id [ID], ObjName[Object Name], Accn[Accn No.] FROM Objects Order BY ObjName;"
DBUtils.ExecuteTableview(SQL1,strQuery,Null,0,tblObjEdit)

frmObject.Show

End If

End Sub

Sub tblObjEdit_SelectedRowChanged(Index As Int, Row() As Object)
If Index = -1 Then Return
ObjID=Row(0)
strQuery="SELECT * FROM Objects where _id ="& ObjID &";"
LoadObjectData
End Sub

Sub LoadObjectData
Dim m As Map

m = DBUtils.ExecuteMap(SQL1, strQuery, Null)

If m.IsInitialized = False Then
txtName.Text = "Please Select..."
Else
'Display data and store for Significance
...
..and this all loads ok
 
Last edited:
Upvote 0
Top