Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uncommitted Changes
Message
 
To
05/01/2010 10:21:02
Hong Yew
People Quest
Malaysia
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01442138
Message ID:
01442289
Views:
63
>Is there anyway I could detect this uncommitted changes and do a TABLEUPDATE() before my app hit the error and crash?
>

Here's what I use:
LPARAMETERS tcCursor, tlSingleRecord
******************************************************************
*  FUNCTION NAME: IsChanged
*	  
*  INPUT PARAMETERS:
*	  tcCursor - Cursor to test
*     tlSingleRecord - Pass in .T. and it will only test the
*       current record.
*  OUTPUT PARAMETERS:
*	  .T. - Cursor is changed
******************************************************************
LOCAL lnRecno, ;
      loSelect, ;
      lcState, ;
      llChanged

llChanged = .F.
      
IF !USED(tcCursor)
   RETURN llChanged
ENDIF
      
* You can replace this line with a SELECT (tcCursor)
loSelect = CREATEOBJECT("CSelect", tcCursor) 
lRecno = RECNO(tcCursor)

IF tlSingleRecord
   lcState = GETFLDSTATE(-1, tcCursor)

   llChanged = "2" $ lcState OR "3" $ lcState OR "4" $ lcState
ELSE
   SCAN
      lcState = GETFLDSTATE(-1, tcCursor)

      llChanged = "2" $ lcState OR "3" $ lcState OR "4" $ lcState
   
      IF llChanged
         EXIT
      ENDIF
   ENDSCAN      
ENDIF

TRY
   GOTO lnRecno IN (tcCursor)
CATCH
ENDTRY

RETURN llChanged
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform