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.
lInvoices.RemoveAllRows
lbID.Value = id
var rs as RowSet = app.db.SelectSQL(“SELECT id, amount FROM invoices WHERE customer=” + id)
try
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)
Next
'rs.close
'End if
't = row.column(“amount”).StringValue
'lInvoices.CellValueAt(lInvoices.LastAddedRowIndex, 1) = t
'total = total + CDbl(t)
'next
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.
Thanks, I have now tried it a different way
lbID.Value = id
Var T as String
Var rs As RowSet
Var Amount As String
Try
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)
Rs.movetonextrow
Wend
rs.Close
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?
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.