Populating WebListBox SQL

Hi All
Just getting started with Xojo moving from another Database software but having issues populating my WebListBox with data from a table, here’s what I have as a Method, the totals work but no columns are populated with the data from the table.


lbID.Value = id

var rs as RowSet = app.db.SelectSQL(“SELECT id, amount FROM invoices WHERE customer=” + id)


Var total As Double
var t as String
'If rs <> Nil then
for each row as databaserow in rs

lInvoices.AddRow row.column("id").StringValue
t = row.column("Amount").StringValue
lInvoices.CellValueAt(lInvoices.LastAddedRowIndex, 1) = t
total = total + CDbl(t)

'End if
't = row.column(“amount”).StringValue
'lInvoices.CellValueAt(lInvoices.LastAddedRowIndex, 1) = t

'total = total + CDbl(t)

lTotal.value = Format(total, “##########.00”)

Catch e as DatabaseException

messagebox e.Message

end try

Much appreciated if anyone could point me to any errors/suggestions how to resolve.



The code looks okay, is maybe some lInvoices.columncount=2 missing? Else you might want to post a screenshot.

Thanks, I have now tried it a different way
lbID.Value = id
Var T as String
Var rs As RowSet
Var Amount As String
Catch error As DatabaseException
MessageBox("Error: " + error.Message)
End Try
rs = app.db.SelectSQL(“SELECT id, Amount FROM invoices WHERE customer=?”, id)
If rs <> Nil Then
While Not rs.AfterLastRow
lInvoices.AddRow(rs.Columnat(0).StringValue, rs.columnat(1).stringvalue)
'total = total + CDbl(t)
End If

The Weblistbox populates but the Amount column (columnat(1) populates with rectangular shapes and not the amounts as string. Also how can I specify that the amount column = Var T so I can total the amounts of this column?



The rectangular shapes points toward an encoding issue with the data either when it was put in the database, or more likely when you are getting it out. What database are you using?

Take a look at https://documentation.xojo.com/api/text/encoding_text/encoding.htmls for further information.

Hi Paul

Going forward we are hopefully going to use Argen to create the tables , currently I am creating the tables using SQL in the built in database creator, the second column in the Weblistbox is the amount column which adds the amount as a string value to one of the tables.

Sorry, if I declare Var T as String how could I declare that the second column = t (Amount)?