Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Two datasessions in a form
Message
De
14/01/2006 02:25:20
 
 
À
13/01/2006 17:55:38
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Divers
Thread ID:
01086752
Message ID:
01086799
Vues:
15
>I have form A which does some work for me. Then I have form B, which does some other work, relying in part on what was previously done in form A (i.e. using records in the tables written by form A).
>
>Now I need to do a shortcut - if some of the work required for an operation in form B wasn't done, I'd need to run some code in form A behind the scenes and to create the needed records.
>
>Since there's actually no code in the forms, and I don't need to show form A at all, just need to call some of the code in its bizobjects. However, there are some cursors that the main bizobj for each form creates, and the framework dictates that their names are the same. Since the structure of these cursors is quite different among these forms (and they are regularly zapped and repopulated), having both bizobjects in the same datasession is more trouble than it's worth.
>
>So I tried to instantiate a session object inside bizB, set DS to its .datasessionID, create the bizB in it (as .addobject() to bizA) and also persist the new DS, assuming that any object's code would execute in the datasession in which it was created.
>
>However, this doesn't work - the DS changes to 3 (new DS that I created) during bizA's .init, but any bizA's code still executes in DS 2 (which is the DS of formB).
>
>Tried to .addObject() frmA instead without the new DS, and the result is the same - its code executes in DS 2 and the cursors get overwritten.
>
>OK, found it. Instead of .addobject("oFrmA", "frmAClass"), I first instantiated the form:
>
>
oTempVar=createobject("frmAClass")
>this.addproperty("oFrmA", oTempVar)
>
>and now it operates in its own DS.
>
>Thanks to everybody for playing auntie Emma with me.
>
>Update: tried the same with just the bizObjA and the session object, works. Thanks again :).
>
>Conclusion, which we may try to check: if an object has a .parent, it is created in parent's DS and operates in it. If it doesn't, then it's the DS in which it was created.

Dragan,
if a object has a .parent, it is not a VFP's object, but an .parent's member and it's datasession
is that of the .parent
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform