Android Question PreferencesDialog for SQL

Enthousiastic

Active Member
Licensed User
Hello , I study the example tutorial " TableAndForms " .
I want the " Editable Table " to load SQL data ( .db database ) instead of .CSV . So I think all the job is done ,
οn " EditableTable " class on line 26 ( sub Initialize ) , how can I change it for loading the above data (sql) ?
Many thanks
Enthousiastic
 

Mahares

Well Known Member
Licensed User
I want the " Editable Table " to load SQL data ( .db database ) instead of .CSV
Your LoadData sub can be something like this:
Here I use a SQLite table with 5 columns, but B4XTable has to have 6 cols, the first col is a blank string to accommodate the 3 buttons: Edit/Delet/Duplicate
B4X:
Sub LoadData
    Dim data As List
    data.Initialize
    If File.Exists(Starter.SafeDirectory, Starter.DBName) Then
        Dim rs As ResultSet
        rs=Starter.SQL.ExecQuery($"SELECT * FROM ${Starter.DBTableName} "$)
        Do While rs.NextRow
            Dim r(6) As String
            r(0)=""
            r(1) = rs.GetInt("RTID")
            r(2) = rs.GetString("RTKind")
            r(3) = rs.GetString("RTNum")
                    
            DateTime.DateFormat = "yyyy-MM-dd"
            r(4) = DateTime.DateParse(rs.GetString("RTDate"))
            DateTime.DateFormat = "MM-dd-yyyy"  'yours may be: dd-MM-yyyy
            r(4)=DateTime.Date(r(4))
            r(4)= DateTime.DateParse(r(4))            
            r(5) = rs.GetString("RTPerson")
            data.Add(r)
        Loop
    Else
        data.Initialize
    End If
    B4XTable1.SetData(data)  
End Sub
You can use the FormBuilder to build your B4XPreferenceDialog template here:
There are other things that will have to also be done to fine tune.
 

Enthousiastic

Active Member
Licensed User
Hello , thank you very much for your remarkable support !!!!!!!
Trying to use the FormBuilder I ran " FormsBuilder " project and the message was that " Is missing jreflection library " which I didn't find it so far to put in the libraries folder. I have the recent version of B4J 8.90 . Any help please and sorry for my ignorance.
 
Top