Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I created a private data session
Message
From
07/06/2002 14:30:34
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00666040
Message ID:
00666118
Views:
20
Hi Nadya,
I think I finally got it to work the way I wanted.
Your pointing out that I don't have to run ds.prg finally did the trick. Turned out I was using another prg-class to store the current datasession and return. It wasn't doing the job, so I was still in the new datasession when the variable used to store it went out of scope, so it wouldn't release the new datasession.


>Bill,
>
>As I told you, you don't have to use ds.prg. Create a session class. Create another session class based on the main session class. Add a method to this class like PrepareViewsForReport() and RunReport(tcReportName)
>
>in your form do
>
>loSession = newobject('MySpecialReportSessionClass','MySpecialReportSessionClass.prg')
>loSession.PrepareViewsForReport()
>loSession.RunReport('myReport')
>release loSession
>
>
>Put a break point before and see, if loSession indeed creates a new private DS.
>
>The key here, that it's your class does the work for you, not the form.
>
>>Hi Sebastian,
>>I don't want the report to have a private datasession, becasue I need to manipulate the view it uses before the report is printed (one thing I need to do is to index the view before printing, I need different indexes for different reports from the same view, so I can't just order the view in the view designer).
>>
>>
ThisForm.oMyReportObject = CREATEOBJECT( "MyReportSessionClass" )
>>This is what I'm trying to find out how to do. How do I create "MyReportSessionClass" and use it in a form?
>>As fas as I can determine, I need to create a prg to hold the definition, and run a prg to create it:
>>
>>ds.prg
>>  Return CreateObject('private_ds')
>>  DEFINE CLASS private_ds as session
>>    ..... open view
>>  ENDDEFINE
>>
>>Form.Method()
>>  local lo
>>  lo = ds()
>>  ..... index view
>>  Report Form whatever
>>
>>but the new datasession doesn't release when lo goes out of scope.
>>
>>
>>>Hi, Bill!
>>>
>>>Follow Garretts advice and use the reports "private datasession" setting!
>>>
>>>BTW: Some background infos about datasessions:
>>>- Every object is unbreakable related to that datasession, which was the active datasession at the time of instantiation of the object!
>>>That means all controls an a form are related to the forms datasession!
>>>- To have a separate datasession for your report you have to associate a session object instead of aggregation:
ThisForm.oMyReportObject = CREATEOBJECT( "MyReportSessionClass" )
>>>And all stuff you have coded in "MyReportSessionClass", e.g. the REPORT commend, runs in the separate private datasession!
Bill Morris
Previous
Reply
Map
View

Click here to load this message in the networking platform