Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data Session with coding ?
Message
 
 
To
04/08/2000 06:24:24
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00400909
Message ID:
00401654
Views:
14
>is it possibe for me to create and destory data session using code inside form which will not affect other form ?
>
>I got error after one form is closed while two form activated.
>
>
>thanks

As Tom suggested, create your forms with a private datasession (i.e. set the Datasession proeprty to 2). This way you can open all the tables you want and they will not affect other forms open at that time.

You can do in this in a number of ways.

1. In the form designer, right-clik on the form, select Dataenvironment and add all the tables/views you need to it. Using this technique, VFP handles opening the tables when the form is launched and closing the tables when the form is released. I recommend this method as it is the easiest and cleanest to implement.

2. You can manually handle this. In the Form Load event (not the Init) add code to open your tables. In the Form's Unload event, add code to close all the tables (i.e. CLOSE TABLES ALL). This command is scoped to the current datasession so it will not affect any other tables opened by any other forms.

The reason for the Load event as opposed to the Init event is because the Init method occurs too late in the instantiation process of the form if you have controls on your form that need access to the data.

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