Armando wrote:James:James Bott wrote:So, if I understand correctly, if the record set record count is zero then oRs:RecordCount() will error out?
Yes.
Rick:
I'm glad to hear that.
Regards
I beg to disagree totally.
oRs:RecordCount returns 0 but DOES NOT error out on Empty RecordSet.
Emptiness of a recordset can be checked either by ( oRs:Bof .and. oRs:Eof ) or by ( oRs:RecordCount == 0 ) safely.
( Note: Our discussion is confined to ClientSide recordsets only ).
When recordset is empty almost all other methods ( bookmark, absoluteposition, etc ) fail.
So, a codeblock like this :
- Code: Select all Expand view
::bBookMark := { |n| If( ::oRs != nil .and. ::oRs:State > 0 .and. ::oRs:RecordCount > 0,
If( Empty( n ), ::oRs:BookMark, ::oRs:BookMark := 0.0 + n ), 0 ) }
should work. Here we are checking not only that oRs is not nil but oRs is in Open State also.
We are also checking that n is not nil and also n is not zero. Setting book mark to zero errors out.
Also in the present win32ole.prg, assigning integer value to BookMark errors out. So we are coverting n to float, if it is integer.
All default codeblocks of xBrowse assume that the datasource ( ADO, RDD, TData, Array/ Hash ) are not nil and are *open*.
They are not written to work when the datasource is made nil or when the datasource is closed.
So if Paint method is called _after closing the datasource_ ( ADO, RDD, etc ), all these codeblocks fail and give runtime errors.
There is no use recoding one or two codeblocks like bBookMark, because Paint method depends on *many* other codeblocks as well.
If we adopt this approach, we need to modify ALL codeblocks for all Set methods to check _each time_, that the datasouce is still not made nil and it is still in open state.
Instead a better and simpler way is to prevent Paint method ( probably Refresh method also ) not to work once the data source is closed or made nil, by setting an appropriate flag.
Incidentally, calling oBrw:End() does not help in any way. It just returns .t. and does nothing else. ( It evaluates oBrw:bValid if any ).