Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Saving problem with updateable local view. Please help
Message
From
12/04/2000 18:22:24
 
 
To
12/04/2000 17:45:49
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00358779
Message ID:
00358991
Views:
9
>>When using TABLEUPDATE with a view, it's a good idea to make it a habit of always checking the return value, and doing something in case it fails. My framework's Save method wraps the TABLEUPDATE function with a check that handles failures.
>
>Do I dare ask if you can give me a copy? Just asking.

I won't give you a copy of my framework, but I'll give you some sample code...

I have a method called UpdateTable that I use instead of calling TABLEUPDATE directly. It makes a call to a Function called HandleError that has generic code in it, and can be overwritten per situation. Both functions are below.
FUNCTION UpdateTable
LPARAMETER tcalias, tlforce

LOCAL llSuccess

IF EMPTY(tcAlias)
	tcAlias = ALIAS()
ENDIF


IF CURSORGETPROP("Buffering", tcAlias) > 1 && Does the table or view have buffering enabled?
	llSuccess = TABLEUPDATE(.T.,tlForce, tcAlias)
	IF llSuccess
		RETURN .T.	
	ELSE
		THISFORM.HandleError(tcAlias)
		RETURN .F.
	ENDIF
ENDIF

ENDFUNC

FUNCTION HandleError
LPARAMETERS tcalias
* This method is called by THIS.UpdateTable() when a tableupdate fails. It gives the user a message and then reverts the changes.

AERROR(errorarray)

MESSAGEBOX('Changes to table "' + ALLTRIM(tcalias) + '" could not be saved. The following reason was returned: '+ CHR(13) +;
	CHR(13) + (errorarray[2]) + CHR(13) + CHR(13) + "Any changes you have made will be lost.", 48,"Update Error")

TABLEREVERT(.T., tcalias)

ENDFUNC
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform