Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to release datasessions?
Message
From
07/04/2010 15:20:38
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01459196
Message ID:
01459239
Views:
73
>Hi,
>
>Sometimes when I am debugging an application I run into a problem during one of the tables updates. And then I cannot close VFP since I am getting message:
>
>Data session #- some number - cannot be released with open transaction.
>
>So far, the only way I found to close VFP in this case is to end it in Task Manager.
>
>Is there a command I can issue in the Command window to release the transactions?
>
>TIA.

I used to run this to "Clean things up"

A simple DO Z and you are ready to go.
* Z.PRG
* Visual FoxPro 6.0

local lcCurDir
PUBLIC glDEBUG

wait wind nowa "Resetting developer environment..."

CloseDataAll()				&& bxk 05.01.02

on shutdown
clear program()
clear program
clear events
* probably not needed anymore
clear read all
clear all
close all
clear macros
clear menu
clear window
clear

set library to
set classlib to
set procedure to 

on key
on error
on escape

set help to
* set resource to f:\devuti60\FOXUSER.DBF

set clock status
set status bar on

lcCurDir = sys(5) + sys(2003)
modi wind screen title lcCurDir + " - " + vers()
_screen.fontname = "Courier New"
_screen.fontsize = 10
_screen.fontbold = .T.

set defa to &lcCurDir

set century on
set debug on
set deleted off
set escape on
set exact off
set hours to 24
set message to
set optimize on
set safety off
set sysmenu to default
set sysmenu on

clear

glDEBUG = .T.

return

*==============================================================================
*!* PROCEDURE CloseDataAll
*
* Purpose:
* This will close and revert all the open tables in all
* the data sessions
*
* Special thanks again to Fletcher Johnson for this portion
* of the reset code which was the winner of the $100 poker
* chip contest from the Error Handling and Debugging session.
*
* Authors:
* David Tansey
* Fletcher Johnson - CIS 72647,1447
*
* From http://fox.wikis.com/wc.dll?Wiki~AppShutDown~VFP
*
********************************************************
PROCEDURE CloseDataAll
#define MAX_SESSIONS 200

LOCAL ;
	lnCurrentDataSession, ;
	lnCurrentWorkArea, ;
	lcErrorCode, ;
	laFiles[1], ;
	li
	
PRIVATE ;
	plError

plError = .F.

lcErrorCode = ON( "error")
ON ERROR plError = .T.


FOR lnCurrentDataSession = 1 TO MAX_SESSIONS

	SET DATASESSION TO ( lnCurrentDataSession )
    
	IF plError
		
		*-- An error occured, must not have
		*-- any data in this datasession
		plError = .f.

	ELSE

		*-- Ok, we have data here
		
		FOR li = 1 TO TXNLEVEL()	&& bxk 05.01.02
			ROLLBACK	
		ENDFOR		
		
		FOR lnCurrentWorkArea = 1 to AUSED( laFiles )
		
			SELECT (laFiles[lnCurrentWorkArea])
			
			IF CURSORGETPROP("BUFFERING") > 1
				TABLEREVERT( .T.)
			ENDIF
			
			USE && close the table
			
			plError = .F.
			
		ENDFOR
	
	ENDIF
	
ENDFOR
  
FLUSH
  
*-- Now reset the error handling code
IF NOT EMPTY( lcErrorCode )
  ON ERROR &lcErrorCode
ELSE
  ON ERROR
ENDIF
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform