Android Question B4XTable

Terradrones

Active Member
Hi, I need help again please! One day this will stop!

I am listing all my coordinates in a B4XTable....Name, Easting, Northing, Elevation and Description.

Two things:
1. I notice that the coordinates have commas "," for every 1000 values? How can I get rid of those commas? In South Africa, we do not show commas or spaces in our values.
2. I have asked this before and got a reply, but I forgot. If there is no description in the SQlite file for "Description", how can I show a blank cell and not "Null"?

Thank you
Michael
 

Terradrones

Active Member
Thank you Erel,

Could you please give me an example how to handle the "null" in B4A? I do not understand the link that you send me.

Thanks
Michael
 
Upvote 0

Terradrones

Active Member
Thank you Erel

Here it is:

SQLite:
[/
Sub ShowTable
    SV.Clear
    SV.DefaultDataFormatter.GetDefaultFormat.GroupingCharacter = ""
    SV.AddColumn("Name", SV.COLUMN_TYPE_TEXT)
    SV.AddColumn("East", SV.COLUMN_TYPE_NUMBERS)
    SV.AddColumn("North", SV.COLUMN_TYPE_NUMBERS)
    SV.AddColumn("Elevation", SV.COLUMN_TYPE_NUMBERS)
    SV.AddColumn("Description", SV.COLUMN_TYPE_TEXT)
    
    Dim Data As List
    Data.Initialize
    If CGlobals.CoordCode=1 Then
        'Site Coords
        Dim rs As ResultSet = CGlobals.sql1.ExecQuery("SELECT Name, East, North, Elevation, Description FROM SCoords")
    else if CGlobals.CoordCode=2 Then
        'Global Coords
        Dim rs As ResultSet = CGlobals.sql1.ExecQuery("SELECT Name, East, North, Elevation, Description FROM GCoords")
    Else
        'Job Coords
        Dim rs As ResultSet = CGlobals.sql1.ExecQuery("SELECT Name, East, North, Elevation, Description FROM Coords")
    End If
    Do While rs.NextRow
        Dim row(5) As Object
        row(0) = rs.GetString("Name")    
        row(1) = NumberFormat2(rs.GetDouble("East"),1,3,3,False)
        row(2) = NumberFormat2(rs.GetDouble("North"),1,3,3,False)
        row(3) = NumberFormat2(rs.GetDouble("Elevation"),1,3,3,False)
        Try
            row(4) = rs.GetString("Description")
        Catch
            row(4)=""
        End Try
        Data.Add(row)
    Loop
    rs.Close
    SV.SetData(Data)
End Sub

]
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Here it is:
Here is one simple way to do it
B4X:
r(4)= rs.GetString("Description")
If r(4) = Null Then r(4) = ""

Or, as Erel mentioned, you can do it in the SELECT statement:
B4X:
Dim strQuery As String =$"SELECT Name, Easting, Northing, Elevation , IFNULL(Description,"") AS descript FROM SCoords"$
Don't just ask one member, the rest of us can help too. Actually, Erel prefers that you do not address one member only
Edited: Actually instead of this: IFNULL(Description,""), it is better to use: IFNULL(Description,'') '2 single quotes
 
Last edited:
Upvote 1
Top