Android Question B4XTable shows duplicated columns

Status
Not open for further replies.

Makumbi

Well-Known Member
Licensed User
Please help this is my code i was trying to display Sentmessages but wen i click on sent messages i get these please views as show please help i would want to display only sent messages but when i click on the button it the first time it doesnt show but the second time it shows duplicated columns please help.

i have attached copy show what happened on the first click (it shows empty empty rows)

B4X:
Sub ShowTable
    If lblSelectedItem.Text="Send" Then
        'B4XTable1.Refresh
        B4XTable1.AddColumn("Datesent", B4XTable1.COLUMN_TYPE_TEXT)
        B4XTable1.AddColumn("SentMessage", 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")
            row(2) = rs.GetString("ID")
            Log(row(1))
            Log(row(3))
            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(1) = "" And  row(2) = "" Then
                Return
            Else
                If row(1) = Null Then row(2) = ""
                row(1) = rs.GetString("SentMessage")
      
                data.Add(row)
            End If
      

        Loop
        rs.Close
        B4XTable1.SetData(data)
        B4XTable1.Refresh
         Return
Else
    B4XTable1.AddColumn("Datesent", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("SentMessage", 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")
        row(2) = rs.GetString("ID")
        Log(row(1))
        Log(row(3))
        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(1) = "" And  row(2) = "" Then
            Return
            Else
            If row(1) = Null Then row(2) = ""
            row(1) = rs.GetString("SentMessage")
      
            data.Add(row)
        End If
      

    Loop
    rs.Close
    B4XTable1.SetData(data)
    'B4XTable1.Refresh
    End If
End Sub
B4X:
Sub btnEdit_Click
    'B4XTable1.Clear

    ShowTable
  
    lblSelectedItem.Text="Send"
End Sub
 

Attachments

  • Screenshot_1554976045.png
    Screenshot_1554976045.png
    35.5 KB · Views: 441
  • Screenshot_1554976215.png
    Screenshot_1554976215.png
    35.7 KB · Views: 352
  • Screenshot_1554977087.png
    Screenshot_1554977087.png
    23.5 KB · Views: 335
Last edited:

Computersmith64

Well-Known Member
Licensed User
Longtime User
So first of all, if you want to check for Null in your ResultSet, you need to use:

B4X:
If row(1) = "null"

Secondly, your screenshots don't show the issue you have described in your post. I don't see any duplicated columns.

- Colin.
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
So first of all, if you want to check for Null in your ResultSet, you need to use:

B4X:
If row(1) = "null"
ives
Secondly, your screenshots don't show the issue you have described in your post. I don't see any duplicated columns.

- Colin.
What is displayed has two extension of https://www.b4x.com/android/forum/attachments/screenshot_1554976045-png.79264/ and this
https://www.b4x.com/android/forum/attachments/screenshot_1554976215-png.79265/ it gives the same columns but with different data out puts but all this is happens when you click on the single buttion
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upload a small project which shows the issue. For everything else it is hard to give any congrete advice. Do NOT forget to include the databasefile.

Away from that i too do not see any duplicates

What is displayed has two extension of https://www.b4x.com/android/forum/attachments/screenshot_1554976045-png.79264/ and this
https://www.b4x.com/android/forum/attachments/screenshot_1554976215-png.79265/ it gives the same columns but with different data out puts but all this is happens when you click on the single buttion

The results are different, yes. But i do not see any duplicates.
 
Last edited:
Upvote 0

Makumbi

Well-Known Member
Licensed User
Upload a small project which shows the issue. For everything else it is hard to give any congrete advice. Do NOT forget to include the databasefile.

Away from that i too do not see any duplicates



The results are different, yes. But i do not see any duplicates.

i have uploaded the compressed project please look at it you see that when the user clicks on sent message it duplicates the columns the first three columns are okay but when you scroll on your right you will see more columns show more informs yet i wanted it to show only three columns . please help.

2. When you click on received it will not delete other columns of sent messages it will continue show additional columns every time you click on those corresponding buttons

thanks in advance
 

Attachments

  • shipedata.zip
    29.7 KB · Views: 225
Upvote 0

Makumbi

Well-Known Member
Licensed User
That is the new upload after collection what you suggested thanks
 

Attachments

  • shipedatanew.zip
    29.7 KB · Views: 200
Upvote 0
Status
Not open for further replies.
Top