SQLSelect

I found this code on the documentation:
https://documentation.xojo.com/api/databases/sqlitedatabase.html#sqlitedatabase-selectsql

' db is a valid connection to a SQLite database
Var rowsFound As RowSet
Try
  rowsFound = db.SelectSQL("SELECT * FROM Customer WHERE PostalCode=" + PostalCode.Text)
  For Each row As DatabaseRow In rowsFound
    ListBox1.AddRow(row.Column("Name").StringValue)
  Next
  rowsFound.Close
Catch error As DatabaseException
  MessageBox("Error: " + error.Message)
End Try

Do you know an elegant way without For Each when your result contains only one row

' Search one Customer with unique ID  
rowFound = db.SelectSQL("SELECT * FROM Customer WHERE ID=?", i)
' rowFound can only contains 0 or 1 row no more 
If Not rowsFound.AfterLastRow then
    ListBox1.AddRow(rowsFound.Column("Name").StringValue)
End If
1 Like

Thanks @David_Cox :pray:

1 Like