this is my first app with xojo
i have set a Shown event of a WebPage. This is the code:
rs is a RecordSet
- If rs <> Nil Then
While Not rs.EOF
If rs.Field("type").StringValue = "table" Then
MsgBox("Table: " + rs.Field("name").StringValue)
- MsgBox(“recordset vuoto, devi aggiungere records”)
- End If
If i debug this whit step-by-step, i see that if rs is Nil (table of database not have row) the step jump to “Wend” and after jump to End.if (line 10).
The line 9 is not execute. Why?
Can you help me?
The RecordSet will not be nil if the database does not have the row. RecordSet will only be nil if there is an issue with your SQL statement. If the database does not have the row you are looking for the RecordSet.RecordCount will be 0.
My untested guess is that
rs in your code is not actually nil.
As Tim said… a RecordSet can be in one of THREE states
- NIL - usually due to an error in the SQL query that was executed
- EMPTY (not to be confused with NIL). When the SQL query is VALID, but no results matched
- NOT NIL, and NOT EMPTY - when the Query suceeded and returned one or more records
Be sure to check for database errors right after you execute the QUERY, and use THAT result instead of checking for NIL
If your RecordSet were nil, your app would crash at line 11.
Thank you!! I did not understand the meaning of Nil
no… “Nothing in there” is “EMPTY”
NIL means there is not even a “there”
It’s me who not digged deep enough.