| Subject |
Re: order of events |
| From |
Gaetano <gaetanodd@hotmail.com> |
| Date |
Sat, 19 Sep 2020 21:25:15 +1000 |
| Newsgroups |
dbase.getting-started |
Hi Ken,
Connect does sound database-related but it is definitely a query event
for ADOQUERY per the Inspector and a sample code in Help. There are
another 3 undocumented events for the ADO query object in fact if you
look at an ADO query object on a form in the Inspector.
Extract from Help:
this.COMPANIES1 = new ADOQUERY(this)
with (this.COMPANIES1)
beforeConnect = class::COMPANIES1_BEFORECONNECT
left = 15.0
top = 4.0
databaseName = "SQLTEST"
sql = "SELECT * FROM KathyTest.dbo.Companies where TYPE >= :TYPE1
and TYPE <= :TYPE2 ORDER BY NAME "
active = true
endwith
this.GRID1 = new GRID(this)
with (this.GRID1)
dataLink = form.companies1.rowset
height = 13.0
left = 1.0
top = 2.0
width = 116.0
endwith
this.rowset = this.companies1.rowset
function COMPANIES1_beforeConnect
this.parameters["TYPE1"] = "A"
this.parameters["TYPE2"] = "Z"
return
I think I'll have to explore another avenue.
Thanks Ken.
Cheers,
Gaetano.
On 19/09/2020 14:52, Ken Mayer wrote:
> On 9/18/2020 5:57 PM, Gaetano wrote:
>>
>> Hi All,
>>
>> I was trying to use the beforeConnect event for an ADO query and it
>> fired before the canOpen event. While I do know the basics about the
>> order for canEvents, beforeEvent and onEvents for a same event type, I
>> don't know how they relate to some other events like in this case
>> beforeConnect.
>
> I am guessing that "beforeConnect" would have to do with the database
> object, not the query ... this event handler doesn't appear in help for
> the ado objects (although I know that the help for ADO isn't as
> up-to-date as it should be). I would check that, first.
>
> However, think it through. *IF* this is a real event handler,
> beforeConnect would logically have to fire before you could open the
> query, because you would have to connect to the database first. Then you
> could attempt a canOpen to open the query itself. Does that make sense?
>
>
>>
>> I guess that my underlying question is whether there is always a
>> built-in order for each and every event to be fired for a given object
>> or do some events fire according to the order they appear in the code?
>> and if there is a hard-coded order, is there somewhere that I can look
>> up the order for a given object?
>
> canEvents fire before the method. So if you have, for example:
>
> canSave() // returns true/false, if false, save() doesn't fire,
> // and therefore onSave() doesn't fire
> Save() // fires if a) no canSave event handler is defined, or
> // if b) a canSave event handler returns true.
> onSave() // only fires after the save method fires, see above.
>
> "before" is not a normal event handler in dBASE, so I can't speak to it
> ... but I would think it would fire either before the canEvent, as noted
> above. I do little with ADO (did some testing for my books, but don't
> use it normally).
>
> Ken
>
|
|