Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datasessions - thisform.release
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00090329
Message ID:
00090405
Views:
36
>>>>>>I have private datasessions for my forms and after the user is finished with a form they do a save (=tableupdate()) or cancel (=tablerevert()). the form is released and I would expect that to be the end of the datasession. The dataenvironment is set up to auto open and close the tables.
>>>>>>
>>>>>>However the datasession remains after the form is long gone. This interferes with the next form which might open up the same tables but with old values.
>>>>>>
>>>>>>Can anyone help me with the right strategy here?
>>>>>
>>>>>Sarah, the most common thing which can happen here - you have some outstanding object references in your form, so form doesn't get released and leaves the datasession open. It is not really gone. Check if you assigned any property to some object. You supposed to set such a property to .NULL. before you release your form.
>>>>>
>>>>>HTH,
>>>>>Nick
>>>>
>>>>Hi Nick. Not sure about your answer. I have a "switchboard" type app and the main form has a method which calls the other forms. Part of it's code is responsible for making sure there are no other forms hanging around:
>>>> m.lncount = _screen.formcount
>>>> if m.lncount >= 2
>>>> for i = 2 to m.lncount
>>>> _screen.forms(i).release()
>>>> endfor
>>>> endif
>>>
>>>>I don't think I understand the bit about assigning properties to objects, I do that all the time - to the form, to it's fields, commands etc.
>>>>
>>>>Sarah
>>>
>>>This code is OK, but the form itself is not able to release itself because of the variables or properties may hold references like
>>>
>>>myVar1 = thisform.grdGrid1
>>>myVar2 = this
>>>thisform.oGrid = thisform.pgfPageFrame.Page2.grdCustomers
>>>
>>>(means you added the property to the form (or used one of the default properties of any form objects for that), and assigned one of the form objects to it (the same goes with variables).
>>>So the property or memory variable may hold object reference, and because of that the object itself doesn't get released. Sometimes it is difficult to find references of that type.
>>>
>>>Nick
>>This is not looking good. Gives me an idea or 2 for some other stuff but...
>>
>>Have done 3 additional tests.
>>1: list memo to var.txt
>>file shows no variables relating to the released form and only the 1 window definition.
>>
>>2: put a wait window in the unload event of the form - it is run. So a form can unload but not get rid of the datasession!?
>>
>>3: put a wait window in the destroy event of the form - it is run!
>>
>>Any ideas? I really appreciate your help!
>
>Sarah,
>
>Nick is in the correct direction for you to be looking in as it the most common problem when forms don't release. Wait windows will still show your code to execute. Everything will execute.....it's just that the form and it's DE will be hanging around afterward. Do you have a property of the form into which you assign an object reference to? THISFORM.oSomeObject = someobject If you do, then in the .Destroy() event of the form you need to put THISFORM.oSomeObject = .NULL. I use Private DataSessions all the time and I make frequent use of properties that are object references and I'm not experiencing the problem that you are having. If I do, it's because I've forgotten to set to .NULL. properties that contain object references.
>
>Steve

Steve is right. Even if Form.Unload is run, it may return .f. and the form is not released completely.

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform