Android Question B4XTable - Null error when using search field

kosmocis

Member
Hi, first, I am very grateful to the community for the tremendous work that has been carried out with the environment and libraries. I always search the forum, but today I came across a problem that I haven't been able to solve in days.

I am implementing a table of type B4XTable to display data stored in a SQLite database. So far so good.
When I try to perform a search in the integrated search field, it performs the corresponding filter, highlighting the searched characters, but this does not last more than a second and the application dies.

Clearly I am not applying any exception handling with the search engine because I am not sure how to do it. I have seen and run the examples posted by Erel and the community.
Hope you can help me, in advance, thanks.

B4A ver: 10.2
B3XTable ver: 1.21


ph.175.jpg
 

kosmocis

Member
Hi Erel, sorry about the screenshot, I'm learning how to interact in the forum.

Yes, it turns out that my data does not contain Nulls.
For example, there is a column that contains a value = "SSD", when using the searcher and writing "SSD", you see that the filter is produced and the corresponding letters are highlighted in red, approximately 1 second, and it falls.

Why will this happen?

thanks!
 
Upvote 0

kosmocis

Member
How are you! I've wasted a while looking for legs to the matter.
The thing is, as suggested, I started a new mini-project where I create a B4X table that reads data from a List, all good.
Surprisingly, for me, the search engine works without any problem.
The only big difference is that my production software reads the data from a row that loads data from a SQLite database.

App snippet with sqlite:
Sub bringFromDB
    Dim cs As Cursor
    cs = managerSql.ExecQuery("SELECT * FROM database")
    Dim result As List
    result.Initialize
    If cs = Null Then
        Log("Error: Storage empty")
    Else
        'Log("Notice: Bringing records...")
        For row = 0 To cs.RowCount - 1
            cs.Position = row
            tmpList.Initialize
            tmpList.Add(cs.GetString2(0))
            tmpList.Add(cs.GetString2(1))
            tmpList.Add(cs.GetString2(2))
            tmpList.Add(cs.GetString2(3))
           
            result.Add(tmpList)
        Next
        cs.Close
    End If
    Return result
End Sub

Sub printData(bringFromDB As List)
    data.Initialize
    For i = 0 To bringFromDB.Size - 1
        tempX = bringFromDB.Get(i)
'        Dim idX As String = tempX.Get(0)
        Dim costoX As Int = tempX.Get(1)
        Dim commentX As String = tempX.Get(2)
        Dim dateX As String = tempX.Get(3)
           
        ' Agrega colxcol a data list
        data.Add(Array( commentX, costoFormatx, dateX ))
        ' Setear Data en tabla
        tableB4x.SetData(data)
    Next
End Sub


I have verified that my data does not save Nulls, the table is listed perfectly and the search filter works but as I mentioned at the beginning of the post, it ends up hanging the application.
In any case, is there a listener that can listen to the search event of the searcher?
Thank you!
 

Attachments

  • financexmaple.zip
    11.6 KB · Views: 301
Upvote 0

Mahares

Expert
Licensed User
Longtime User
have verified that my data does not save Nulls, the table is listed perfectly and the search filter works but as I mentioned at the beginning of the post, it ends up hanging the application.
Several things that are ambiguous:
1. The project you exported has a totally different code from the one you post in the above post.
2. This line: tableB4x.SetData(data) in your code should be outside the For Next loop. Could be the source of your app hanging up if you have many records.
3. Same problem in your project: B4XTable.SetData(data) needs to be outside.
4. You are referring to a SQLite table in your above code, but you are not using a SQLite table in your posted project.
5. You refer to a table called database in your above code. It is not advisable to use 'database' as a table name as it is a reserved word.
6. I ran the project and it works fine, perhaps because it is not representative of what you are trying to solve when using a database.
7. Your best bet is to export a project with the database instead of just a list.
 
Last edited:
Upvote 0

kosmocis

Member
Hi! I am very excited today. After an extensive night of compilation work, my project has been without any errors.

Responding to Mahares:

2. This line: tableB4x.SetData(data) in your code should be outside the For Next loop. Could be the source of your app hanging up if you have many records.

In effect, this line was unnecessarily running many times, although it never affected performance. Changed.

Several things that are ambiguous:
1. The project you exported has a totally different code from the one you post in the above post.

Precisely. The commented code is an extraction of the code of the final project, which because of its heaviness and amount of resources I cannot upload. On the other hand, the example I uploaded contextualizes what I needed to do, except for the data source.

RESOLVED
I really don't know at what point the error stopped with the searcher. But after reviewing the display of the data in the columns, these could not have been ordered correctly, so I always recommend checking that well and checking that you do not have null data entered in the data source.

Thank you all very much!
 
Upvote 0
Top