Friday, December 7, 2007

Gotcha: Dangling Datasession Left After Running Report

If you run a report using a ReportListener from the FFC directory, and you're using a successor listener, and that report is run from a form with a private datasession, you end up with a dangling datasession after the report completes. If you keeping running reports in this manner, you keep building up more dangling datasessions. I don't think I have to tell you the consequences of a long day of running reports like this!

I posted this on Microsoft's Connect site so anyone who wants to confirm, vote, comment, etc. about this bug, the ID number is 316134.

Here are the steps to reproduce the problem:

1. Create a form
2. Set the datasession to private
3. Add a button with the following code in the click

lcReport = SYS(2015)

CREATE CURSOR junk (test I)
FOR ln = 1 TO 10
INSERT INTO Junk VALUES (ln)
ENDFOR

CREATE REPORT &lcReport FROM Junk

ThisForm.AddProperty('oListener', null)

SET CLASSLIB TO 'C:\Program Files\Microsoft Visual FoxPro
9\Ffc\_reportlistener'
ThisForm.oListener = CREATEOBJECT('_ReportLIstener')
ThisForm.olistener.listenertype = 1

THisForm.AddProperty('o2', null)
ThisForm.o2 = CREATEOBJECT('ReportListener')
ThisForm.oListener.Successor = ThisForm.o2

REPORT FORM &lcReport OBJECT ThisForm.olistener


4. Run the form
5. Click the button
6. Close the report
7. Close the form
8. Open the data session window
9. Notice an Unknown(#) session.

2 comments:

Anonymous said...

Ick.

davidfung said...

Thanks for posting this bug, which I can reproduced and voted yes in MS Connect.

This is a serious bug as chaining to an update listener is quite a common thing to do!