Hello all, i haven't really played too much with B4J, i'am working on a very simple application which connects to a remote database on my hosting service, i'am using a tableview which shows the results of a search query, this all works perfect, but when i clear the items from the tableview the application crashes with the following error.
below is the relevant code, please let me know if there is anything i'm missing
Thanks All,
Walter
Error occurred on line: 176 (Main)
java.lang.NullPointerException
at b4j.example.main._tblsearchresults_selectedrowchanged(main.java:367)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:226)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA$2.run(BA.java:165)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
below is the relevant code, please let me know if there is anything i'm missing
B4X:
Sub searchresults_QueryComplete (Success As Boolean, Crsr As ResultSet)
Dim sql2 As SQL = Sender
If Success Then
Log("success retrieving searchresults: " & Success)
If tblsearchresults.Items.Size > 0 Then
tblsearchresults.Items.Clear 'Here i clear the items from the previous search
End If
Do While Crsr.NextRow
Dim row(7) As Object
Log("first name: " & Crsr.GetString("First_Name") & " " & "Last Name :" & Crsr.GetString("Last_Name") & " " & "Pet's Name: " & Crsr.GetString("Pet_Name"))
row(0) = Crsr.GetString("First_Name")
row(1) = Crsr.GetString("Last_Name")
row(2) = Crsr.GetString("Pet_Name")
row(3) = Crsr.GetString("Sex")
row(4) = Crsr.GetString("Breed")
row(5) = Crsr.GetString("Date")
row(6) = Crsr.GetString("Clips_and_Comments")
tblsearchresults.Items.Add(row)
Loop
Crsr.Close
sql2.Close
searchresults.Show
Else
Log("error occurred retrieving search results")
End If
End Sub
Thanks All,
Walter