Try
rowsFound = app.db.SelectSQL("select * from Dokumente where Datum > '01.01.2010' order by Datum asc")
For Each row as DatabaseRow in rowsFound
If rowsFound <> Nil Then
If row.Column("Datum").Value <> Nil Then
MessageBox(row.Column("Datum")) // shows first date from Dokumente correctly
var dat As Date = Row.Column("Datum").DateValue // No Errors in Code but crashes with dat = NIL // 'DateTime.Now' works!
Label_date.Text = dat.SQLDate // Convert to yyyy-mm-dd and set to 'Label_date.Text'
ListBox1.AddRow(row.Column( "Bezeichnung").StringValue, Label_date.text, row.Column( "Name").StringValue, row.Column( "Betrag").StringValue, row.Column( "ID").StringValue) // OK
Else
ListBox1.AddRow ""
End If
End if
Next
Catch error as DatabaseException
MessageBox("Error")
End Try
Is better if you create a new topic instead of asking on a topic that is already marked as solved. People may miss your problem. Maybe a moderator can split your question (and my comment) into its own thread.
What version of Xojo are you using?
It is not recommended to use MessageBox as a debugging tool. From the documentation:
Warning
You should avoid using MessageBox for displaying debugging messages. The displaying of the Message Box will alter event order and may give unexpected results. Instead use the Debugger, System.DebugLog or your own logging mechanism.
Can you comment that line and try again (you can use DebugLog if you want). Maybe that will help.
Another thing you can do is put var dat as new date before the For Each row...
Your messageBox shows that the string value of Datum is 18.11.2023 which is a localised date, not convertible directly into a date variable. I would either use DateTime where one of the constructors allows you to read localised string dates or convert the Datum column to contain unlocalised data. Makes it easier to have the Select really only show valid documents because the comparison string starts with the year.
And yes, maybe like in the other thread wrap a check for Nil into that method.
As Ulrich said, if your dates are saved as 18.11.2023 then you will need to change your code from:
to something like:
Var dat As datetime = DateTime.FromString(Row.Column("Datum").StringValue, Locale.Current)
Note: if you use the application with other locale (US for example) your stored dates of 18.11.2023 will cause an error. Maybe you want to review the documentation about locale and change Locale.Current to one that match the saved database date.