B4A Library [Class] Flexible Table

This thread will be used by Erel, Melamoud and myself to discuss / post new releases of the Table class.

The table class is a flexible UI component that enable scrollable table like UI, with sortable columns, multiselect rows etc

the table is very efficient, maintaining labels only for visible rows

old thread with details : http://www.b4x.com/forum/additional...view-supports-tables-any-size.html#post110901

The class depend on following libraries:
- StringUtils (standard)
- SQL (standard)
- JavaObject (standard)
- B4XCollections (standard)
- ScrollView2D (additional)

List of major features.
1. scrollable table UI
2. sortable columns
3. select a row, cell or multi select rows
4. callback for selection / click a cell / row
5. callback for long click action
6. read / write to CSV file

Current version --> 3.35 Custom View
Current version --> 1.44 Class

Other complementary routines:

Load data with the Remote Database Connector.


EDIT: LucaMs has written a routine to fill a table with a Remote Database Connector query result see post 182.
The routine hasn't been added into the Class for the reasons explained in post 183.
A sample program can be found HERE.

Code:
B4X:
'load data from a RDC Request
'Result = DBResult object got from a RDC request
'AutomaticWidths  True > set the column widths automaticaly
'Written by LucasMs
Public Sub LoadRDCResult(Result As DBResult, AutomaticWidths As Boolean)
    cAutomaticWidths = AutomaticWidths
    NumberOfColumns = Result.Columns.Size
    innerClearAll(NumberOfColumns)

    Dim Headers(NumberOfColumns) As String
    Dim ColumnWidths(NumberOfColumns) As Int
    Dim HeaderWidths(NumberOfColumns) As Int
    Dim DataWidths(NumberOfColumns) As Int
    Dim col, row As Int
    Dim str As String
    For col = 0 To NumberOfColumns - 1
        Headers(col) = Result.Columns.GetKeyAt(col)
        If AutomaticWidths = False Then
            ColumnWidths(col) = 130dip
            HeaderWidths(col) = 130dip
            DataWidths(col) = 130dip
        Else
            HeaderWidths(col) = cvs.MeasureStringWidth(Headers(col), Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth
            DataWidths(col) = 0

            Dim FieldValue As Object
            For row = 0 To Result.Rows.Size - 1
                Dim Record() As Object = Result.Rows.Get(row)
                FieldValue = Record(col)
                If GetType(FieldValue) = "java.lang.String" Then
                    DataWidths(col) = Max(DataWidths(col), cvs.MeasureStringWidth(str, Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth)
                End If
            Next
            ColumnWidths(col) = Max(HeaderWidths(col), DataWidths(col))
        End If
    Next
    SetHeader(Headers)
    SetColumnsWidths(ColumnWidths)

    For Each Record() As Object In Result.Rows
        Dim R(NumberOfColumns) As String
        Dim FieldV As String
        For col = 0 To NumberOfColumns - 1
            FieldV = Record(col)
            R(col) = FieldV
        Next
        AddRow(R)
    Next
End Sub

This is another routine updated by cimperia in post #392 using a Map for the columns and a List for the rows.
B4X:
'load data from a RDC Request
'A RDC request returns a DBResult object, therefore this method
'could be called as is:
'LoadRDCResult(DBResult.Columns, DBResult.Rows, True)
'AutomaticWidths  True > set the column widths automaticaly
'Written by LucasMs
Public Sub LoadRDCResult(Columns As Map, Rows As List, AutomaticWidths As Boolean)
  cAutomaticWidths = AutomaticWidths
  NumberOfColumns = Columns.Size
  innerClearAll(NumberOfColumns)

  Dim Headers(NumberOfColumns) As String
  Dim ColumnWidths(NumberOfColumns) As Int
  Dim HeaderWidths(NumberOfColumns) As Int
  Dim DataWidths(NumberOfColumns) As Int
  Dim col, row As Int
  Dim str As String
  For col = 0 To NumberOfColumns - 1
    Headers(col) = Columns.GetKeyAt(col)
    If AutomaticWidths = False Then
      ColumnWidths(col) = 130dip
      HeaderWidths(col) = 130dip
      DataWidths(col) = 130dip
    Else
      HeaderWidths(col) = cvs.MeasureStringWidth(Headers(col), Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth
      DataWidths(col) = 0

      Dim FieldValue As Object
      For row = 0 To Rows.Size - 1
        Dim Record() As Object = Rows.Get(row)
        FieldValue = Record(col)
       If GetType(FieldValue) = "java.lang.String" Then
         DataWidths(col) = Max(DataWidths(col), cvs.MeasureStringWidth(str, Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth)
       End If
      Next
      ColumnWidths(col) = Max(HeaderWidths(col), DataWidths(col))
    End If
  Next
  SetHeader(Headers)
  SetColumnsWidths(ColumnWidths)

  For Each Record() As Object In Rows
    Dim R(NumberOfColumns) As String
    Dim FieldV As String
    For col = 0 To NumberOfColumns - 1
      FieldV = Record(col)
      R(col) = FieldV
    Next
    AddRow(R)
  Next
End Sub


Load data from a MSMariaDB database.

Another routine for loading data from a MSMariaDB database can be found in post#727.
Thanks to @Magma.

Updates:
EDIT: 2024.04.21 Version 3.35
Replaced the original sorting functions by new ones kindly provided by forum member RB Smissaert.
Amended first scroll scrolling back to 0
Amended Header with transparent color

EDIT: 2024.01.13 Version 3.33
Changed possible values for DataType
TEXT and NUMBER become T, R and I
Amended problem with column colors
Amended problems with SetHeaderColors and SetHeaderTextColors

Version 3.32
Amended Header and HeaderFirst problem in SaveCSVFromTable
Moved If (lblStatusline... from AddRow to ShowRow

Version 3.31
Added SingleLine property for the Designer
Added StatusLineHeight as a property
Added FastScrollLabelMaxChars as a property

EDIT: 2021.06.28 Version 3.30
Added a check for none numeric values for numeric sorting.

EDIT: 2021.06.28 Version 3.29
Amended problem with column colors
Version 3.28
Added NumberOfColumns in the code
Added TopRowIndex method
Version 3.27
Amended MultiSelect EDIT: 2020.09.02 Version 3.26
Amended problem with sort with remove accents
Amended problem with SetRowColorN
Added SetCellAlignmentColN method
Added SetHeaderAlignmentColN method

EDIT: 2020.08.05 Version 3.24
Amended problem with JumpToRowAndSelect not being selected.
Amended error when setting RowHeight before the table initialized

EDIT: 2020.06.19 Version 3.22
Amended error in the insertRowAt routine.

EDIT: 2020.05.25 Version 3.21
Amended bug with TextSize in fixed columns

EDIT: 2020.05.16 Version 3.20
Added fast scroll feature
Version 3.19
Improved automatic width calculation and hidden columns
Version 3.18
Added a check in RemoveRowColorN to ensure that Row is not out of bounds
Added ShowRow event
Amended automatic width calculations
Amended hidden column width problem

EDIT: 2020.04.21 Version 3.17
Amended HeaderHight problem with fixed columns

EDIT: 2020.04.21 Version 3.16
Amended two errors.

EDIT: 2020.04.14 Version 3.14
Added the methods below
- LoadSQLiteDB4(SQLite As SQL, Query As String, AutomaticWidths As Boolean)
loads SQLite data with data type checking
- LoadSQLiteDB5(SQLite As SQL, Query As String, Values() As String, AutomaticWidths As Boolean).
loads SQLite data with data type checking , similar to LoadSQLiteDB4 but for parametrized queries.
- GetColumnDataTypes As String(), returns an Array with the data type for each column.
- GetColumnDataType(Column As Int) As String, returns the data type of the fiven column.
Added the InnerTotalWidth property, read only.
Added multiple first fiexed columns
Added line colors

EDIT: 2020.03.10 Version 3.10
Amended bug reported HERE

EDIT: 2020.03.06 Version 3.09
Amended bug reported HERE.

EDIT: 2020.02.29 Version 3.08
Amended SetHeaderTypefaces method problem reprted HERE.
Added HeaderTypeface property.

EDIT: 2020.01.08 Version 3.07
Amended bug ShowStatisLine = False property bug.
Added MultiSelect property to Designer properties.
You need to open and close the Designer when you use the new version the first time to make the MultiSelect property active.

EDIT: 2019.12.28 Version 3.06
Amened some bugs

EDIT: 2019.12.25 Version 3.05
Added FirstColumnFixed property which allows to fix the first column.
Attention: You need to open and close the Designer to make the new property active.

EDIT: 2019.11.15 Version 3.04
- Added SelectedRowTextColor and SlectedCellTextColor properties
- Added ZeroSelections property, True > when a selected row is pressed it will be unselected False > it remains selected.

EDIT: 2019.11.12 Version 3.03
- Changed JumpToRowAndSelect(Row As Int, Col As Int) to JumpToRowAndSelect(Col As Int, Row As Int)
- Changed LoadSQLiteDB2 signature. Replaced the possible values from "T", "I", "R" to "TEXT", "NUMBER" for coherence with SetColumnDataTypes.
- Added internal sorting bitmaps, avoids loading the image files into the Files folder.
- Added two new properties: SortBitmapWidth and SortBitmapColor.
- Added SetCustomSortingBitmaps method, which allows to use custom bitmaps instead of the internal ones.
Attention: You need to open and close the Designer to make the new properties active.
Attention: You need to invert the parameters in JumpToRowAndSelect.

EDIT: 2019.07.04 Version 3.02
Amended error reported in post #887

EDIT: 2019.06.26 Version 3.01
Amended SingleLine property setting in the code

EDIT: 2019.04.05 Version 3.00
Amended SetColumnColors and SetTextColors
Removed Reflection library dependency

EDIT: 2018.04.11 Version 2.29
Version 2.27
set the two variables sortedCol and sortingDir to Public instaed of Private
added RemoveAccent routine for sorting with accented characters
Version 2.28
Added SetHeaderTypeFaces
Added SortRemoveAccents property
Version 2.29
Added SaveTableToCSV2 with a user defined separator character

EDIT: 2018.04.11 Version 2.26
added LoadSQLiteDB3 method using SQLExec2 instead of SQLExec
The query can include question marks which will be replaced with the values in the array.

EDIT: 2018.03.27 Version 2.25
amended minor errors
added UpdateCell method

EDIT: 2017.11.19 Version 2.22
improved JumpToRowAndSelect scrolls horizontally to the selected column
improved setHeaderHeight
added padding for status bar Label

EDIT: 2017.06.27 Version 2.19
Replaced DoEvents by Sleep(0)
Asked HERE

EDIT: 2017.06.27 Version 2.19
Replaced DoEvents by Sleep(0)
Asked HERE

EDIT: 2017.05.16 Version 2.18
Amended error reported HERE.

EDIT: 2017.03.09 Version 2.17
Amended error reported HERE.

EDIT: 2017.03.09 Version 2.15
Amended error reported here, Event signatures
#Event: CellClick(col As Int, row As Int)
#Event: CellLongClick(col As Int, row As Int)

EDIT: 2016.12.05 Version 2.14
Added NumberOfColumns and NumberOfRows as Public variables.
Amended error reported here.

EDIT: 2016.12.05 Version 2.13
Amended error reported here.
Added NumberOfColumns as a property for the Designer.

EDIT: 2016.07.30 Version 2.10
Amended error with TextAlignment and HeaderTextAlignment reported in post #606

EDIT: 2016.03.15 Version 2.00
Added CustomView support.
This version can be compiled into a library.
Changes between the previous versions and version 2.00
For a Table added in the Designer, this is new
No need to initialize nor add it onto a parent view
'For a Table added in the Designer, this is new
'No need to initialize nor add it onto a parent view

For a Table added in the code:
The Initialize routine has been splittend into two routines.
New:
Initialize (CallBack As Object, EventName As String)
InitializeTable (vNumberOfColumns As Int, cellAlignement As Int, showStatusL As Boolean)

'Example:
Table1.Initialize(Me, "Table1")
Table1.InitializeTable(5, Gravity.CENTER_HORIZONTAL, True)


Old:
Initialize(CallBack As Object, EventName As String, vNumberOfColumns As Int, cellAlignement As Int, showStatusL As Boolean)
Example:
Table1.Initialize(Me, "Table1", 5, Gravity.CENTER_HORIZONTAL, True)

EDIT: 2015.04.29 Version 1.43
As the modifications in LoadSQLiteDB don't work in all cases I went back.
LoadSQLiteDB as in version 1.40
Added LoadSQLiteDB2 where the column data types must be given.

EDIT: 2015.04.26 Version 1.42
Changed he LoadSQLiteDB routine, version 1.41 didn't work as expected.
The final solution was suggested by cimperia HERE.

EDIT: 2015.04.16 Version 1.41
Changed the LoadSQLiteDB routine according to the error reported in the SQL issue thread
and the SQLite Cursor GetString versus GetDouble thread.
The problem appears with numbers bigger than 999999.
I left version 1.40 in case of problems.
I tested it with a few databases, but I am not sure if it works in all cases.

EDIT: 2015.03.05
Amended bugs reported in posts #383 and #386
Added SetAutomaticWidths routine

EDIT: 2015.02.19
Amended the problem alignment reported in post # 378

EDIT: 2015.02.13
Amended the problem of rows not shown reported in post # 371

EDIT: 2015.01.09
Added header aligments

EDIT: 2014.08.14
Added HeaderHeight property
Amended RowColor problem reported in post #260

EDIT: 2014.08.10
Added SortColumn property asked in post #266
Added UseColumnColors ColumnColors and HeaderColors propeties

EDIT: 2014.05.10 Added RowHeight as a property

Screenshot:

1589638570453.png
 

Attachments

  • TableV1_44.zip
    44.8 KB · Views: 2,187
  • 1589638550715.png
    1589638550715.png
    31.8 KB · Views: 1,614
  • TestFastScroll.zip
    50.6 KB · Views: 1,466
  • Table.bas
    152.2 KB · Views: 199
  • TableV3_35.zip
    110 KB · Views: 275
Last edited:

klaus

Expert
Licensed User
Longtime User
minVisibleRow and maxVisibleRow are the previus numbers of visible rows.
currentMin and currentMax are the current numbers of visible rows, these values are calculated at the beginning of Sub SV_ScrollChanged.
And at the end of Sub SV_ScrollChanged minVisibleRow and maxVisibleRow are updated.
minVisibleRow = currentMin
maxVisibleRow = currentMax
 

grupotgr

Member
Licensed User
Longtime User
@grupotgr
Is this what you are looking for?
Clicking on the header City or Country opens a serch view.
The selected item is highlighted in the table.
I modified a bit the SearchView Class and set the Data List in the Table Class to Public.

Sorry klaus, I was not coming to work, now I'm resuming my activities! I'll try what you suggest and I keep you informed.
Thanks for the help!
 

luciano deri

Active Member
Licensed User
Longtime User
Hello Klaus, in versione 1.43 you use DoEvents, but this instruction is deprecated on versione 7.01. Could i replace with sleep(0) without problems? Or Could i continue to use DoEvents?
 

klaus

Expert
Licensed User
Longtime User
You can replace thise code
B4X:
'Makes the given row visible.
Public Sub JumpToRow(Row As Int)
    SV.VerticalScrollPosition = Row * cRowHeight
    DoEvents
    SV.VerticalScrollPosition = Row * cRowHeight
    DoEvents
End Sub

'Makes the given row visible and det it's row and colum as selected.
Public Sub JumpToRowAndSelect(Row As Int, Col As Int)
    Dim rc As RowCol
  
    rc.Row = Row
    rc.Col = Col
    SelectRow(rc)
    SV.VerticalScrollPosition = Row * cRowHeight
    DoEvents
    SV.VerticalScrollPosition = Row * cRowHeight
    DoEvents
End Sub
By this code:
B4X:
'Makes the given row visible.
Public Sub JumpToRow(Row As Int)
    Sleep(0)
    SV.VerticalScrollPosition = Row * cRowHeight
End Sub

'Makes the given row visible and det it's row and colum as selected.
Public Sub JumpToRowAndSelect(Row As Int, Col As Int)
    Dim rc As RowCol
  
    rc.Row = Row
    rc.Col = Col
    SelectRow(rc)
    Sleep(0)
    SV.VerticalScrollPosition = Row * cRowHeight
End Sub

@Erel
The Sleep(0) is needed when JumpToRow is called either from Activity_Create or Activity_Resume.

The Class has been updated to versions 1.44 and 2.19 in post#1.
 
Last edited:

Magma

Expert
Licensed User
Longtime User
Hope this routine helps who works with MSMariaDB:

Just add it at table class:

B4X:
Public Sub LoadMSMariaDB2(Data1 As List, meta As Map, AutomaticWidths As Boolean, ColumnDataTypes() As String)

If Data1.Size < 1 Then
    Return
End If
 
cAutomaticWidths = AutomaticWidths


    mNumberOfColumns = meta.get("ColumnCount")

    innerClearAll(mNumberOfColumns)
 
 
    Dim Headers(mNumberOfColumns) As String
    Dim ColumnWidths(mNumberOfColumns) As Int
    Dim HeaderWidths(mNumberOfColumns) As Int
    Dim DataWidths(mNumberOfColumns) As Int
    Dim cColumnDataType(mNumberOfColumns) As String
    Dim col, row As Int
    Dim ii As Long
    Dim dd As Double
    Dim str As String
    Dim fields As Map=Data1.Get(0)
    For col = 0 To mNumberOfColumns - 1
        If ColumnDataTypes(col) = "T" Then
            cColumnDataType(col) = "TEXT"
        Else
            cColumnDataType(col) = "NUMBER"
        End If
        Headers(col) = fields.GetKeyAt(col)
        If cAutomaticWidths = False Then
            ColumnWidths(col) = 130dip
            HeaderWidths(col) = 130dip
            DataWidths(col) = 130dip
        Else
            HeaderWidths(col) = cvs.MeasureStringWidth(Headers(col), Typeface.DEFAULT, cTextSize) + ExtraWidth
            DataWidths(col) = 0
            For row = 0 To Data1.size - 1
                Dim fields As Map=Data1.Get(row)
                str = fields.GetValueAt(col)
                If str <> Null Then
                    Select ColumnDataTypes(col)
                        Case "I"
                            ii = NumberFormat2(fields.GetValueAt(col),1,0,0,False)
                            str = ii
                        Case "R"
                            dd = NumberFormat2(fields.GetValueAt(col),1,2,2,False)
                            str = dd
                    End Select
                Else
                    str = ""
                End If
                DataWidths(col) = Max(DataWidths(col), cvs.MeasureStringWidth(str, Typeface.DEFAULT, cTextSize) + ExtraWidth)
            Next
            ColumnWidths(col) = Max(HeaderWidths(col), DataWidths(col))
        End If
    Next
    SetHeader(Headers)
    SetColumnsWidths(ColumnWidths)

    For row = 0 To Data1.size - 1

        Dim R(mNumberOfColumns), str As String
     
        Dim fields As Map=Data1.Get(row)
        For col = 0 To mNumberOfColumns - 1
            str = fields.GetValueAt(col)
            If str = Null Then
                R(col) = ""
            Else
                Select ColumnDataTypes(col)
                    Case "I"
                        ii = NumberFormat2(fields.GetValueAt(col),1,0,0,False)
                        R(col) = ii
                    Case "R"
                        dd = NumberFormat2(fields.GetValueAt(col),1,2,2,False)
                        R(col) = dd
                    Case "T"
                        R(col) = fields.GetValueAt(col)
                    Case Else '"BLOB"
                        R(col) = ""
                End Select
            End If
        Next
        AddRow(R)
    Next
 

End Sub

Way to view MSMariaDB to table is the above:

B4X:
Sub Process_Globals
dim db as MSMaria
end sub
    db.Initialize("MSQL","yourdomain","username","password","database-maria")

db.QueryASync("select * from products;","show")


Sub DisableStrictMode
Dim jo As JavaObject
jo.InitializeStatic("android.os.Build.VERSION")
If jo.GetField("SDK_INT") > 9 Then
    Dim policy As JavaObject
    policy = policy.InitializeNewInstance("android.os.StrictMode.ThreadPolicy.Builder", Null)
        policy = policy.RunMethodJO("permitAll", Null).RunMethodJO("build", Null)
        Dim sm As JavaObject
        sm.InitializeStatic("android.os.StrictMode").RunMethod("setThreadPolicy", Array(policy))
    End If

End Sub


Sub MSQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int)
    Log($"Connected = ${Connected}"$)
End Sub


Sub MSQL_ExecResult(meta As Map)
    Log(meta)
End Sub
Sub MSQL_BatchResult(batch As Map)
    Log(batch)
End Sub

Sub MSQL_QueryResult(Data As List, meta As Map)

    Dim m As Map = meta
    'Dim r As List
 
 
    Select Case m.Get("TaskID")
        Case "show"

            Dim cts(3) As String '3 are my fields
            cts(0)="T"
            cts(1)="T"
            cts(2)="I"
            Table1.LoadMSMariaDB2(Data, meta, True, cts)
    End Select

    db.CloseDatabase
 
End Sub

Sub MSQL_ListTables(tables As List, ms As Long)
    Log("MSQL_ListTables("&ms&"ms)")
    For i=0 To tables.Size-1
        'Log("Table "&tables.Get(i))
    Next
End Sub

MSMariaDB is a chargeable library

But if you buy it - you can use my routine for free..
 
Last edited:

Aries Abedes

Member
Licensed User
Hi,

I am trying to use the new flexible table version(2.19) in conjunction with the new DBrequestManager with resumable subs and jRDC2. This is the code where it will download data from ms sql then save it locally to sqlite

B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    'Private reqManager As DBRequestManager
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private btnSearch As Button
    Private edtSearch As EditText
    Private lblCount As Label
    Private tblDRList As Table
    Private Toolbar As ACToolBarDark
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("lDRList")
 
'    If FirstTime Then
'        reqManager.Initialize(Me, "http://192.168.1.2:9999/rdc") 'Office
'    End If
 
    Dim TestConn As HttpJob
    TestConn.Initialize("TestConn", Me)
    TestConn.Download("http://192.168.1.2:9999/test")
    TestConn.GetRequest.Timeout = 3000
 
    CheckSQLiteIfEmpty
    CallSpDownloadDR(Starter.intAreaID, Starter.strReleaseDate)
 

     
 
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

'------------------------------------------------------------------------------
'|JOB DONE - For ASYNC CALL - UI STILL RESPOND While PROCESSING SQL REQUEST   |
''------------------------------------------------------------------------------
Sub JobDone(Job As HttpJob)
    If Job.Success = True Then
        Select Job.JobName
'            Case "DBRequest"
'                reqManager.HandleJobAsync(Job, "ReqManager")
            Case "TestConn"
                ToastMessageShow("Connection to RDC server was successful.", False)
        End Select
    Else
        Log("Error: " & Job.ErrorMessage)
        Msgbox("Failed to connect to RDC server. Please check connection and try again." , "Server connection error:")
        Activity_Resume
    End If
    Job.Release
End Sub

'Sub ReqManager_Result(result As DBResult)
'     
'    '------------------------------------
'    '| LOAD DR RESULT            |
'    '------------------------------------
' 
'    If result.Tag = "DRDownload" Then 'query tag
'        tblDRList.LoadRDCResult(result,True)
'        Log(result)
'        If tblDRList.Size = 0 Then
'            Msgbox("No released DR for " & Starter.strLSRArea, "Download error:")
'            Return
'        Else
'            SaveToSQLite
'            StartActivity(aDRList)
'         
'            Activity.Finish
'        End If
'        Log(result)
'    End If
'  
'End Sub


Sub CreateRequest As DBRequestManager
    Dim req As DBRequestManager
    req.Initialize(Me, "http://192.168.1.2:9999/rdc")
    Return req
End Sub

Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = Name
    cmd.Parameters = Parameters
    Return cmd
End Sub



Sub CallSpDownloadDR(aID As Int, rDate As String)
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("dr_download", Array(aID, rDate))
    Wait for (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        req.PrintTable(res)
        tblDRList.LoadRDCResult(res, True)
        If tblDRList.Size = 0 Then
            Msgbox("No released DR for " & Starter.strLSRArea, "Download error:")
            Return
        Else
            SaveToSQLite
            StartActivity(aDRList)
            'Activity.Finish
        End If
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub


Sub Toolbar_MenuItemClick (Item As ACMenuItem)
 
End Sub

Sub tblDRList_CellClick(col As Int, row As Int)
 
End Sub

Sub btnSearch_Click
 
End Sub

Sub Activity_KeyUp (KeyCode As Int) As Boolean
    StartActivity(Main)
    Activity.Finish
End Sub



Sub CheckSQLiteIfEmpty
    Dim Count As Int
    Count = Starter.SQl1.ExecQuerySingleResult2 ("SELECT COUNT(entryid) FROM tblcsvdrreceivingdtl WHERE receivedby IS NULL", Array As String())
 
    If Count <> 0 Then
        DeleteUnsignedDR
    End If
End Sub

Sub SaveToSQLite
    Dim tblDrFromMSSQL As List
    Dim Items() As String
    tblDrFromMSSQL.Initialize
    For i = 0 To tblDRList.Size - 1
        Items = tblDRList.GetValues(i)
        Dim m As Map
        m.Initialize
        m.Put("CSVID",Items(0)) 'You will need to replace the columns names with the correct names
        m.Put("CSVDATE", Items(1))
        m.Put("LSR_AREAID", Items(2))
        m.Put("ENTRYID", Items(3))
        m.Put("DRID", Items(4))
        m.Put("RE_ENTRYID", Items(5))
        m.Put("EHDI", Items(6))
        m.Put("DRNO", Items(7))
        m.Put("DELDATE", Items(8))
        m.Put("OUTLETNAME", Items(9))
        m.Put("RET_NAME", Items(10))
        m.Put("USERID", Items(11))
        tblDrFromMSSQL.Add(m)
    Next
 
    Try
        DBUtils.InsertMaps(Starter.SQL1, "tblcsvdrreceivingdtl", tblDrFromMSSQL)
        lblCount.Text = tblDRList.Size
        tblDrFromMSSQL.Clear
        Msgbox("Download complete.", "Download status:")
    Catch
        Log(LastException)
    End Try
     
 

End Sub

Sub DeleteUnsignedDR
    Starter.SQl1.ExecNonQuery("DELETE FROM tblcsvdrreceivingdtl WHERE receivedby IS NULL")
End Sub

And then i get this error below

B4X:
Logger connected to:  SKK chronos_ace

--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (aselectarea) Create, isFirst = true **
** Activity (aselectarea) Resume **
5
MAKATI
** Activity (aselectarea) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (adownloaddr) Create, isFirst = true **
** Activity (adownloaddr) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httputils2service) Start **
Tag: null, Columns: 12, Rows: 139
CSVID    CSVDATE    LSR_AREAID    ENTRYID    DRID    RE_ENTRYID    EHDI    DRNO    DELDATE    OUTLETNAME    RET_NAME    USERID 
2.0    02/23/2017    5.0    17.0    819875.0    393585.0    1.0    1189648.0    02/22/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    18.0    819874.0    393586.0    1.0    1189647.0    02/22/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    19.0    819984.0    393461.0    1.0    1189890.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    20.0    819985.0    393462.0    1.0    1189891.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    21.0    819987.0    393463.0    1.0    1189892.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    22.0    820005.0    393468.0    1.0    1189893.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    23.0    820009.0    393469.0    1.0    1189894.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    24.0    820010.0    393470.0    1.0    1189895.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    25.0    820011.0    393471.0    1.0    1189896.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    26.0    820316.0    393560.0    1.0    1190264.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    61.0    820269.0    393520.0    1.0    1189912.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    62.0    820272.0    393521.0    1.0    1189913.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    63.0    820273.0    393522.0    1.0    1189914.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    64.0    820264.0    393515.0    1.0    1189909.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    65.0    820265.0    393516.0    1.0    1189910.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    66.0    820266.0    393517.0    1.0    1189911.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    67.0    820298.0    393545.0    1.0    1189922.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    68.0    820301.0    393548.0    1.0    1189923.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    69.0    820303.0    393549.0    1.0    1189924.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    70.0    820285.0    393534.0    1.0    1189919.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    71.0    820286.0    393535.0    1.0    1189920.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    72.0    820291.0    393538.0    1.0    1189921.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    73.0    820282.0    393531.0    1.0    1189918.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    74.0    820280.0    393529.0    1.0    1189917.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    75.0    820277.0    393526.0    1.0    1189916.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    76.0    820275.0    393524.0    1.0    1189915.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    77.0    819960.0    393580.0    1.0    1189682.0    02/22/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    78.0    819961.0    393581.0    1.0    1189683.0    02/22/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    79.0    819962.0    393582.0    1.0    1189684.0    02/22/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    80.0    819956.0    393583.0    1.0    1189681.0    02/22/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    81.0    820314.0    393558.0    1.0    1189930.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    82.0    820315.0    393559.0    1.0    1189931.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    83.0    820313.0    393557.0    1.0    1189929.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    84.0    819965.0    393584.0    1.0    1189685.0    02/22/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    85.0    820306.0    393551.0    1.0    1189925.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    86.0    820309.0    393553.0    1.0    1189926.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    87.0    820310.0    393554.0    1.0    1189927.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    88.0    820311.0    393555.0    1.0    1189928.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    122.0    819876.0    393564.0    1.0    1189649.0    02/22/2017    MER-GLOPOS    MERCURY DRUGSTORE - GLORIETTA NORTHMALL    0.0 
2.0    02/23/2017    5.0    123.0    820022.0    393477.0    1.0    1189900.0    02/23/2017    MER-GLOPOS    MERCURY DRUGSTORE - GLORIETTA NORTHMALL    0.0 
2.0    02/23/2017    5.0    124.0    820024.0    393478.0    1.0    1189901.0    02/23/2017    MER-GLOPOS    MERCURY DRUGSTORE - GLORIETTA NORTHMALL    0.0 
2.0    02/23/2017    5.0    125.0    820025.0    393479.0    1.0    1189902.0    02/23/2017    MER-GLOPOS    MERCURY DRUGSTORE - GLORIETTA NORTHMALL    0.0 
2.0    02/23/2017    5.0    126.0    819877.0    393595.0    1.0    1189650.0    02/22/2017    MER-TAGPOS    MERCURY DRUGSTORE - TAGUIG    0.0 
2.0    02/23/2017    5.0    127.0    820016.0    393473.0    1.0    1189897.0    02/23/2017    MER-TAGPOS    MERCURY DRUGSTORE - TAGUIG    0.0 
2.0    02/23/2017    5.0    128.0    820017.0    393474.0    1.0    1189898.0    02/23/2017    MER-TAGPOS    MERCURY DRUGSTORE - TAGUIG    0.0 
2.0    02/23/2017    5.0    129.0    820018.0    393475.0    1.0    1189899.0    02/23/2017    MER-TAGPOS    MERCURY DRUGSTORE - TAGUIG    0.0 
2.0    02/23/2017    5.0    27.0    820312.0    393556.0    1.0    1190263.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    28.0    819951.0    393571.0    1.0    1189678.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    29.0    819953.0    393572.0    1.0    1189680.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    30.0    819952.0    393573.0    1.0    1189679.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    31.0    819947.0    393574.0    1.0    1189674.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    32.0    819941.0    393575.0    1.0    1189672.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    33.0    819945.0    393576.0    1.0    1189673.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    34.0    819948.0    393577.0    1.0    1189675.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    35.0    819949.0    393578.0    1.0    1189676.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    36.0    819950.0    393579.0    1.0    1189677.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    37.0    820254.0    393509.0    1.0    1189731.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    38.0    820255.0    393510.0    1.0    1189732.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    39.0    820256.0    393511.0    1.0    1189733.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    40.0    820258.0    393512.0    1.0    1189734.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    41.0    820261.0    393513.0    1.0    1189735.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    42.0    820263.0    393514.0    1.0    1189736.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    43.0    820267.0    393518.0    1.0    1189737.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    44.0    820268.0    393519.0    1.0    1189738.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    45.0    820274.0    393523.0    1.0    1189739.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    46.0    820276.0    393525.0    1.0    1189740.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    47.0    820278.0    393527.0    1.0    1189741.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    48.0    820279.0    393528.0    1.0    1189742.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    49.0    820281.0    393530.0    1.0    1189743.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    50.0    820283.0    393532.0    1.0    1189744.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    51.0    820284.0    393533.0    1.0    1189747.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    52.0    820307.0    393552.0    1.0    1190262.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    53.0    820324.0    393563.0    1.0    1190267.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    89.0    820305.0    393550.0    1.0    1190261.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    90.0    820233.0    393494.0    1.0    1189716.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    91.0    820234.0    393495.0    1.0    1189717.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    92.0    820235.0    393496.0    1.0    1189718.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    93.0    820236.0    393497.0    1.0    1189719.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    94.0    820237.0    393498.0    1.0    1189720.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    95.0    820238.0    393499.0    1.0    1189721.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    96.0    820239.0    393500.0    1.0    1189722.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    97.0    820242.0    393501.0    1.0    1189723.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    98.0    820244.0    393502.0    1.0    1189724.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    99.0    820245.0    393503.0    1.0    1189725.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    100.0    820246.0    393504.0    1.0    1189726.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    101.0    820250.0    393505.0    1.0    1189727.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    102.0    820251.0    393506.0    1.0    1189728.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    103.0    820252.0    393507.0    1.0    1189729.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    104.0    820253.0    393508.0    1.0    1189730.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    105.0    819918.0    393588.0    1.0    1189664.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    106.0    819931.0    393589.0    1.0    1189666.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    107.0    819934.0    393590.0    1.0    1189667.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    108.0    819935.0    393591.0    1.0    1189668.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    109.0    819936.0    393592.0    1.0    1189669.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    110.0    819938.0    393593.0    1.0    1189671.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    111.0    819937.0    393594.0    1.0    1189670.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    112.0    820299.0    393546.0    1.0    1190259.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    113.0    820300.0    393547.0    1.0    1190260.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    114.0    820292.0    393539.0    1.0    1190253.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    115.0    820293.0    393540.0    1.0    1190254.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    116.0    820294.0    393541.0    1.0    1190255.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    117.0    820295.0    393542.0    1.0    1190256.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    118.0    820296.0    393543.0    1.0    1190257.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    119.0    820297.0    393544.0    1.0    1190258.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    120.0    820287.0    393536.0    1.0    1189748.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    121.0    820290.0    393537.0    1.0    1189749.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    151.0    820097.0    393489.0    1.0    1189711.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    152.0    820098.0    393490.0    1.0    1189712.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    153.0    820099.0    393491.0    1.0    1189713.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    154.0    820100.0    393492.0    1.0    1189714.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    155.0    820101.0    393493.0    1.0    1189715.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    54.0    820035.0    393485.0    1.0    1189905.0    02/23/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    55.0    820036.0    393486.0    1.0    1189906.0    02/23/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    56.0    820037.0    393487.0    1.0    1189907.0    02/23/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    57.0    820038.0    393488.0    1.0    1189908.0    02/23/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    58.0    819878.0    393587.0    1.0    1189651.0    02/22/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    130.0    820020.0    393476.0    1.0    1189707.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    131.0    820015.0    393472.0    1.0    1189706.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    132.0    819988.0    393464.0    1.0    1189702.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    133.0    819992.0    393465.0    1.0    1189703.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    134.0    819994.0    393466.0    1.0    1189704.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    135.0    819997.0    393467.0    1.0    1189705.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    136.0    819982.0    393459.0    1.0    1189700.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    137.0    819983.0    393460.0    1.0    1189701.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    138.0    820026.0    393480.0    1.0    1189708.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    139.0    820028.0    393482.0    1.0    1189709.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    140.0    820319.0    393561.0    1.0    1190265.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    141.0    820321.0    393562.0    1.0    1190266.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    142.0    819869.0    393565.0    1.0    1189644.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    143.0    819870.0    393566.0    1.0    1189645.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    144.0    819872.0    393567.0    1.0    1189646.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    145.0    819860.0    393568.0    1.0    1189641.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    146.0    819865.0    393569.0    1.0    1189642.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    147.0    819867.0    393570.0    1.0    1189643.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    148.0    820030.0    393484.0    1.0    1189710.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    149.0    819980.0    393457.0    1.0    1189698.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    150.0    819981.0    393458.0    1.0    1189699.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    59.0    820027.0    393481.0    1.0    1189903.0    02/23/2017    SHANGRILA    MAKATI SHANGRI-LA HOTEL & RESORT,INC.    0.0 
2.0    02/23/2017    5.0    60.0    820029.0    393483.0    1.0    1189904.0    02/23/2017    SHANGRILA    MAKATI SHANGRI-LA HOTEL & RESORT,INC.    0.0 
Error occurred on line: 506 (Table)
java.lang.RuntimeException: Object should first be initialized (View).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.ViewWrapper.setWidth(ViewWrapper.java:135)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
    at com.emeraldheadway.dr.table._setcolumnswidths(table.java:887)
    at com.emeraldheadway.dr.table._loadrdcresult(table.java:239)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:19)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:240)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
    at anywheresoftware.b4a.BA$2.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5728)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

and this is the sub from the table class where it tells the error

B4X:
Public Sub SetColumnsWidths(Widths() As Int)
    ' clone (keep) Widths
    Dim col, row As Int
 
 
    Dim SavedWidths(Widths.Length) As Int
    Dim ColumnWidths(Widths.Length) As Int
    Dim HeaderWidths(Widths.Length) As Int
    If cAutomaticWidths = False Then
        For col = 0 To Widths.Length - 1
            SavedWidths(col) = Widths(col)
            ColumnWidths(col) = Widths(col)
            HeaderWidths(col) = Widths(col)
            DataWidths(col) = Widths(col)
        Next
    Else
        For col = 0 To Widths.Length - 1
            SavedWidths(col) = Widths(col)
            ColumnWidths(col) = Widths(col)
        Next
    End If
 
    Dim v As View
    Dim w As Int
 
    For col = 0 To Widths.Length - 1
        v = Header.GetView(col)
        w = Max(2dip, Widths(col) - cLineWidth)
        v.Width = w
        If col > 0 Then
            v.Left = Header.GetView(col - 1).Left + Widths(col - 1)
        End If
    Next
    Header.Width = Header.GetView(Widths.Length - 1).Left + Widths(Widths.Length - 1)
    SV.Panel.Width = Header.Width
    Dim lbls() As Label
    For row = 0 To visibleRows.Size - 1
        lbls = visibleRows.GetValueAt(row)
        For col = 0 To lbls.Length - 1
            lbls(col).SetLayout(Header.GetView(col).Left, lbls(col).Top, _
                Header.GetView(col).Width, cRowHeight - cLineWidth)
        Next
    Next
    lblStatusLine.Width = Header.Width
    internalPanel.Width = Header.Width
End Sub

Using the old modules seem to work fine where I jump from sub to sub to process the command but when I try to convert it this error appears. I'm sorry if i cannot explain it well. Hope someone can help me.

Thank you.

Aries
 

Attachments

  • DRzip.zip
    51.3 KB · Views: 290
Last edited:

klaus

Expert
Licensed User
Longtime User
1) In the Activity aDownloadDR you are using a Table tblDRList which is not defined in the layout nor added to the Activity !?

2) Set a breakpoint in line 125 StartActivity(aDRList) in aDownloadDR to see if the the table is loaded form there.

3) Set a breakpoint at line 1860 innerClearAll(mNumberOfColumns) in the Table class and check if the value of mNumberOfColumns in the line 1859 is bigger than 0.
 

Aries Abedes

Member
Licensed User
Hi Klaus,

Thank you for the support but unfortunately I was not able to get pass no. 2. I will test further and update what would be the workaround for this. For now I will just continue to use the old DBRequestManager module.

Thank you.

Aries
 

Aries Abedes

Member
Licensed User
Hi,

I have tried to comment the
B4X:
SetColumnsWidths (ColumnWidths)
from
B4X:
Public Sub LoadRDCResult(Result As DBResult, AutomaticWidths As Boolean)
then I was able to continue but only get a single row from the result and the innerClearAll(mNumberOfColumns) in the Table class has a value of 5.

Any suggestions?

Thank you.
 

Aries Abedes

Member
Licensed User
I'm so sorry... please disregard my post. It was my fault.. I'm still using the old LoadRDCResult Sub that I may have messed up.

Thank you.

Aries
 

vecino

Well-Known Member
Licensed User
Longtime User
Hi, why are there two different versions?
What makes them different?
Tablev2.19 and Tablev1.44
 

vecino

Well-Known Member
Licensed User
Longtime User
Thank you very much for the information.
Then I will use version 2.19 :)
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, now how do I tell you how many columns?
And how much is the width of each column?
Thank you.
 

Claudio Oliveira

Active Member
Licensed User
Longtime User
Starting to use this class now, and I noticed that the StatusLine is too close to the table border, so I added the following line to InitTable sub, before the pnlTable.AddView(internalPanel, 0, 0, cWidth, 0) line (class line 414):

B4X:
SetPadding(lblStatusLine, 4dip, 2dip, 4dip, 2dip)

I'm not sure this is the right approach, but it aligned the StatusLine with the table header and improved it's readability.

Regards
 
Top