Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with Datasession
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00533035
Message ID:
00533131
Views:
14
>Hello,
>
>I have an object that contains serveral functions. One of them does an update of serveral fields of a table.
>I use that function from within a form. This form uses a private datasession.
>My problem now is that when I call the function, my data environment goes to the default datasession so that my function doesn't find the tables I have opened in my private datasession. Is there a way to tell my function (object) not to use the default datasession but the private datasession of the form (without using "set datasession to") ??
>
>
>Greetings,
>
>Hans

Hans,
Objects exist in the datasession they are created in. Because of this fact, here are three suggestions:

1. Instead of methods of an object, create a procedure file with the necessary functions. The datasession will not change and the code will act within the datasession of whatever called it. For functions that manipulate objects bounded by datasessions, this is sometimes a prudent action.

2. As Mark suggested, instantiate a version of the object as part of the form. You can eiher drop it on the form or instatiate it in the Load/Init and assign it to a form-level property.

3. Pass the datasession of the form to the function. I don't know why you don't want to do this. It's perfectly legal and acceptable. As long as there are no bound controls as part of the object, you can change datasessions all day long without any problems/issues. FYI, this is how SDT works.

I've used all three and I don't really have a preference.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform