>>I tried this code and it works correctly for me. The SET DATASESSION TO correctly activates the right data session. i.e. 1
>>My question must be why are you trying to set the datasession anyway ?
>
>As you may have seen in my reply, I found the problem.
>
>As for the user of changing data session, there is various reasons for that. In my case, I have the defaut data session which contains some control files where I need to switch to it sometimes to get some values.
Hi Michel,
One technique I use to solve the problem you mention is to create a global object. If you execute the following code any time during your application startup when the default datasession is active, the object will remember that it was instantiated in the default datasession.
PUBLIC goControlFileInterface
goControlFileInterface = CREATEOBJECT("cControlFileInterface")
DEFINE CLASS cControlFileInterface AS CUSTOM
PROCEDURE ControlFileMethod1
*-- Put code here to work on tables in default datasession
ENDPROC
ENDDEFINE
If you ever make a call to this object e.g. goControlFileInterface.ControlFileMethod1() VFP will take care of changing datasessions for you automatically. It will change it to the default datasession upon entry to the method and will return back to its previous datasession on exit. As long as you always know what datasession was active when an object is instantiated you should never have to change the datasession property manually.
Darrel
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement