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)
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
Last edited: