My business object is based on the custom class and can optionally use a private data session. The SetPrivateDataSession() method looks like this:
If This.lPrivateDataSession
This.oSession = CreateObject("Session")
This.oSession.Name = This.Name
Set Datasession To This.oSession.DataSessionID
Set Deleted On
Set Multilocks On
EndIf
If I want to force the object to use the current data session, I pass a parameter in the NewObject() that gets passed to the objects Init(). Here is the Init() method:
Lparameters llDefaultDataSession
...
If llDefaultDataSession
This.lPrivateDataSession = .f.
EndIf
This.SetPrivateDataSession()
...
Are you looking for something like this?
>i found it lurking somewhere.. thanks!
>
>the main reason why i was looking for the session object is to design a generic business object that could be used within a form or even just on its own...
>
>in vfp6, since the dataenvironment doesn't have the datasession and datasessionid properties, i'd need to create a data session from scratch if needed... if the business object will be used within a form, then the builtin datasession of the form takes over, however, if the business object will be used without a form (say as an object that provides services to the application but there is no form in direct contact with the user) the session object should create the datasession so that the dataenvironment can use it..
>
>the sequence of events will be such:
>
>if used on a form:
>1. cursors are loaded into memory (but not data)
>2. dataenvironment is loaded
>3. business object is loaded
>4. form is loaded
>
>if not used on a form:
>1. cursors are loaded into memory (but not data)
>2. dataenvironment is loaded
>3. business object is loaded
>
>
>in this case, the business object should first test if it is contained within a form, if it is, then just pass on the datasessionid of the form to the business object, if the business object is not contained in a form, create a session class to be used by the dataenvironment...
>
>is this making sense? or am i missing something? any special concerns i have to watch out for?