Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datasession behavior
Message
 
To
23/09/1997 19:13:55
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00051207
Message ID:
00051503
Views:
43
>>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform