Android Question Unable to show data from the table

Makumbi

Well-Known Member
Licensed User
Good morning members i wish to thank mangojack for the effort he used to help me in solving this problem but after speeding alot time i found out what was making my data not to display when i enable columns in this code from the showsent messages and show received messages i can see the data now the main problem is when the these columns are enabled as advised but Erel and Mangojack this creates mutiples columns yet i wanted only three columns please help me out because when you create them at Activity_Create(FirstTime As Boolean) it shows the columns but when you click no data is displayed i have attached this small project with explaining on some activities that takes in the project please help

B4X:
    'DateColumn = B4XTable1.AddColumn("Date", B4XTable1.COLUMN_TYPE_TEXT)
    'B4XTable1.AddColumn("Sms", B4XTable1.COLUMN_TYPE_TEXT)
    'B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_TEXT)
 

Attachments

  • Shipnewnow.zip
    23.6 KB · Views: 113

Erel

B4X founder
Staff member
Licensed User
Longtime User
Put a breakpoint on line 172 and you'll see that the list is empty:
SS-2019-04-15_11.29.10.png
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
1. Clicking in Received SMS button displays Table with no data. The first column title = "Date Received" (Displaying 1-0 of 0)
2. Clicking on Sent SMS button displays same Table with no data. The first column title = "Date Sent" (Displaying 1-0 of 0)
3. Clicking on Send SMS does nothing (It used to display a send message dialogue ... Which I might have disabled previously)
4. I do not see any form of Duplicated columns

I explained previously the Sub ReplySMS does not get any / return data from the http job . Which in turn populates the Recievedsms db Table ..
which is the data to be displayed when you click Received SMS button

The Sent SMS button displays data in Sentmessages db Table ... I cannot see where / when it is populated with data.

I can only see one single set of B4XTable.AddColumn(...... ) So I don't know where these phantom duplicate columns come from.

I can see no changes to this sample whatsoever from when I uploaded it last.... Have you uploaded the correct one ??
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
1. Clicking in Received SMS button displays Table with no data. The first column title = "Date Received" (Displaying 1-0 of 0)
2. Clicking on Sent SMS button displays same Table with no data. The first column title = "Date Sent" (Displaying 1-0 of 0)
3. Clicking on Send SMS does nothing (It used to display a send message dialogue ... Which I might have disabled previously)
4. I do not see any form of Duplicated columns

I explained previously the Sub ReplySMS does not get any / return data from the http job . Which in turn populates the Recievedsms db Table ..
which is the data to be displayed when you click Received SMS button

The Sent SMS button displays data in Sentmessages db Table ... I cannot see where / when it is populated with data.

I can only see one single set of B4XTable.AddColumn(...... ) So I don't know where these phantom duplicate columns come from.

I can see no changes to this sample whatsoever from when I uploaded it last.... Have you uploaded the correct one ??
When i run the code below i can see the data from the table with columns added i can see the information
B4X:
Sub ShowSentSMS
    ' When i enable these fileds i can see the messages but after disabling them i do not see the data from the table  yet enabling this creates duplication of columns
    DateColumn = B4XTable1.AddColumn("Date", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Sms", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_TEXT)
    
    
    data.Initialize
    Dim rs As ResultSet = Starter.SQL1.ExecQuery("SELECT DISTINCT Datesent,Sms as SentMessage,ID FROM Sentmessages")
    Do While rs.NextRow
        Dim row(4) As Object
        row(0) = rs.Getstring("Datesent")
        row(1) = rs.GetString("SentMessage")
        
        'Log(row(0))
        'Log(row(1))
        'Log(row(2))
        '& " " & rs.GetString("LastName")
        row(2) = rs.GetString("ID")
        'Some of the fields are Null. We need to convert them to empty strings:
        If row(2) = Null Then row(2) = ""
        row(1) = rs.GetString("SentMessage")
        data.Add(row)
    Loop
    rs.Close
    B4XTable1.SetData(data)
    
    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    
    Dim pnl As B4XView = DateColumn.CellsLayouts.Get(0) 'header panel
    pnl.GetView(0).Text = "DateSent"
    
End Sub

But when i run the code only with this code as it is below i do not get the data to show show
B4X:
    data.Initialize
    Dim rs As ResultSet = Starter.SQL1.ExecQuery("SELECT DISTINCT Datesent,Sms as SentMessage,ID FROM Sentmessages")
    Do While rs.NextRow
        Dim row(4) As Object
        row(0) = rs.Getstring("Datesent")
        row(1) = rs.GetString("SentMessage")
        
        'Log(row(0))
        'Log(row(1))
        'Log(row(2))
        '& " " & rs.GetString("LastName")
        row(2) = rs.GetString("ID")
        'Some of the fields are Null. We need to convert them to empty strings:
        If row(2) = Null Then row(2) = ""
        row(1) = rs.GetString("SentMessage")
        data.Add(row)
    Loop
    rs.Close
    B4XTable1.SetData(data)
    
    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    
    Dim pnl As B4XView = DateColumn.CellsLayouts.Get(0) 'header panel
    pnl.GetView(0).Text = "DateSent"
    
End Sub
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Apologies ... I did open you previous upload in error.

But apart from a few extra comments regarding reason for http calls I still see no change whatsever from last time.

I still get no data to be displayed in the Table .

The only data arrives in Activity_Create ... which is inserted in SMSlist db Table ... which is Not displayed anywhere.

B4X:
Dim rs As ResultSet = Starter.SQL1.ExecQuery("SELECT DISTINCT Daterecieved,Sms as RecievedMessage,ID FROM Recievedsms")
Log("Row Count >>>> " & rs.RowCount)

Row Count >>>> = 0 ......... And same for the Sentmessages table

B4X:
Sub ShowSentSMS
    ' When i enable these fileds i can see the messages but after disabling them i do not see the data from the table  yet enabling this creates duplication of columns
    DateColumn = B4XTable1.AddColumn("Date", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Sms", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_TEXT)

YES .... This is the reason you end up with Duplicate Columns
N0 .... I do not suddenly see data when they are enabled ... Just Duplicate columns !

Add columns once at Activity_Create only and get rid of those other AddColumn calls in both subs.
We have already solved renaming that first column later.

Get me some data and I might be able to help.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
In addition ... did you intake @Erels recommendation in post #2. ?
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
Apologies ... I did open you previous upload in error.

But apart from a few extra comments regarding reason for http calls I still see no change whatsever from last time.

I still get no data to be displayed in the Table .

The only data arrives in Activity_Create ... which is inserted in SMSlist db Table ... which is Not displayed anywhere.

B4X:
Dim rs As ResultSet = Starter.SQL1.ExecQuery("SELECT DISTINCT Daterecieved,Sms as RecievedMessage,ID FROM Recievedsms")
Log("Row Count >>>> " & rs.RowCount)

Row Count >>>> = 0 ......... And same for the Sentmessages table

B4X:
Sub ShowSentSMS
    ' When i enable these fileds i can see the messages but after disabling them i do not see the data from the table  yet enabling this creates duplication of columns
    DateColumn = B4XTable1.AddColumn("Date", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Sms", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_TEXT)

YES .... This is the reason you end up with Duplicate Columns
N0 .... I do not suddenly see data when they are enabled ... Just Duplicate columns !

Add columns once at Activity_Create only and get rid of those other AddColumn calls in both subs.
We have already solved renaming that first column later.

Get me some data and I might be able to help.

the table SMSlist is populated with data when you click on sendsms with the send sms that button is supposed to load registered members into the spinner so that the user can select any registered person then send the message . and when the message is sent it is stored in sentmessages table which can later be viewed by the user and also the table recivedsms stored replied sms from the interface which is on the server that is managed buy another user. that is how it works
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I have just Sent an SMS and had confirmation the message was sent .... Still No Data.

1. Concentrate on getting data from the ReplySMS Sub which then populates the Receivedsms dbTable.
Then we can display It in the Table.

Presently there is NO data being recieved.

Fix this problem first and forget all the other issues. They will get solved in due course.

Again ... Did you intake @Erels recommendation in post #2. ?


End of Line

.
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
In addition ... did you intake @Erels recommendation in post #2. ?
yes i traced the code after adding this it shows the data
B4X:
Sub ShowSentSMS
    ' When i enable these fileds i can see the messages but after disabling them i do not see the data from the table  yet enabling this creates duplication of columns
    DateColumn = B4XTable1.AddColumn("Date", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Sms", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_TEXT)
   
   
    data.Initialize
    Dim rs As ResultSet = Starter.SQL1.ExecQuery("SELECT DISTINCT Datesent,Sms as SentMessage,ID FROM Sentmessages")
    Do While rs.NextRow
        Dim row(4) As Object
        row(0) = rs.Getstring("Datesent")
        row(1) = rs.GetString("SentMessage")
       
        'Log(row(0))
        'Log(row(1))
        'Log(row(2))
        '& " " & rs.GetString("LastName")
        row(2) = rs.GetString("ID")
        'Some of the fields are Null. We need to convert them to empty strings:
        If row(2) = Null Then row(2) = ""
        row(1) = rs.GetString("SentMessage")
        data.Add(row)
    Loop
    rs.Close
    B4XTable1.SetData(data)
   
    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   
    Dim pnl As B4XView = DateColumn.CellsLayouts.Get(0) 'header panel
    pnl.GetView(0).Text = "DateSent"
   
End Sub

but when i run with your code where there
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
yes i traced the code after adding this it shows the dat

The attached sample now works as expected. (partly)

By sending an SMS , data now appears in Table (press Sent SMS)

There is still no data being returned from ReplySMS Sub ... so no records are being shown

It is possible the error was caused by a Creating 3 Column Table ... but passing 4 element array to .SetData method (did not have time to test)

The sample has been tidied up a bit. Whether this is the the correct approach , I am unsure.
Ideally I think the Table should be hidden until needed .

At the very least your latest issue has been solved.
 

Attachments

  • SMS Sample 4.zip
    29.1 KB · Views: 100
Upvote 0

Makumbi

Well-Known Member
Licensed User
The attached sample now works as experected. (partly)

By sending an SMS , data now appears in Table (press Sent SMS)

There is still no data being returned from ReplySMS Sub ... so no records are being shown

It is possible the error was caused by a Creating 3 Column Table ... but passing 4 element array to .SetData method (did not have time to test)

The sample has been tidied up a bit. Whether this is the the correct approach , I am unsure.
Ideally I think the Table should be hidden until needed .

At the very least your latest issue has been solved.
thank you very much
 
Upvote 0
Top