Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
'Syntax Error' in Local views
Message
De
22/02/2000 14:11:36
Keith Jones
The It Studio Limited
Brentwood, Royaume Uni
 
 
À
21/02/2000 18:56:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00335122
Message ID:
00335524
Vues:
22
Hi Henry,

I am not too sure what you are trying to say. I can say how I get views
to function.

1) Be safe. Create views in code. Keep all view creation in a single
programme which can be run to create all your views in one hit.
Remember to re run this programme if you modify table structures,
otherwise you will get an error when opening forms 'Table Definition
Changed'. Example code (it's mine so it can't be too good).
CREATE SQL VIEW Contact_V AS ;
SELECT * FROM Contact WHERE ;
IDKContact=?FLibnWhere ;
ORDER BY Surname, Forename

2) In the form LOAD

* VIDE=Views In Data Environment.
PUBLIC ARRAY FLibaVIDE(1) && Released in form INIT event.
* Either a form or formset.
IF AMEMBERS(FLibaVIDE, &FLibDataEnvType, 2) < 1
=MESSAGEBOX("Developer Message-:" + CHR(13) + CHR(13) + ;
"There are no views contained within this forms" + CHR(13) + ;
"DataEnvironment. This programme will cancel.",48, ;
"No Views In Form DataEnvironment")
CANCEL
ENDIF

FOR FLibNLC=1 TO ALEN(FLibaVIDE)
* Relationships are also put into the array.
* Bypass cursor property settings if a relationship.
IF NOT "RELATION" $ UPPER(FLibaVIDE(FLibNLC))
FLibcCursorName=EVALUATE(FLibDataEnvType + "." + ;
ALLTRIM(FLibaVIDE(FLibNLC)) + ".Alias")
ENDIF
ENDFOR

3) In the FORM INIT

LOCAL FLibCurrArea, FLibPoxyFaultFound, FLibnLC

FLibCurrArea=SELECT()
FLibPoxyFaultFound=.F.

FOR FLibNLC=1 TO ALEN(FLibaVIDE)
* Relationships are also put into the array.
* Bypass cursor property settings if a relationship.
IF NOT "RELATION" $ UPPER(FLibaVIDE(FLibNLC))
FLibCursorName=EVALUATE(IIF(TYPE("THIS.DATAENVIRONMENT")="O", ;
"THIS.DATAENVIRONMENT", "THISFORMSET.DATAENVIRONMENT") + "." + ;
ALLTRIM(FLibaVIDE(FLibNLC)) + ".Alias")
SELECT (FLibCursorName)
IF NOT CURSORSETPROP("Buffering",5,FLibCursorName)
MESSAGEBOX("Developer Message-: " + CHR(13) + CHR(13) + ;
"Unable to set BUFFERING property to 5 in cursor " + ;
UPPER(FLibCursorName) + ".", 48, ;
"This Application Will Close - Function Form INIT")
FLibPoxyFaultFound=.T.
EXIT
ENDIF
IF NOT CURSORSETPROP("SendUpdates",.T.,FLibCursorName)
MESSAGEBOX("Developer Message-: " + CHR(13) + CHR(13) + ;
"Unable to set SendUpDates property in cursor " + ;
UPPER(FLibCursorName) + ".", 48, ;
"This Application Will Close - Function Form INIT")
FLibPoxyFaultFound=.T.
EXIT
ENDIF
IF NOT CURSORSETPROP("Prepared",.T.,FLibCursorName)
MESSAGEBOX("Developer Message-: " + CHR(13) + CHR(13) + ;
"Unable to set Prepared property in cursor " + ;
UPPER(FLibCursorName) + ".", 48, ;
"This Application Will Close - Function Form INIT")
FLibPoxyFaultFound=.T.
EXIT
ENDIF
* UpdatableFieldList property is by default all fields, except
* primary key and timestamp.
IF FSIZE("TimeStamp", FLibCursorName) < 1
MESSAGEBOX("Developer Message-: " + CHR(13) + CHR(13) + ;
"Unable to set KeyFieldList property in cursor " + CHR(13) + ;
UPPER(FLibCursorName) + ", as it does not contain" + CHR(13) + ;
"a TimeStamp field.", 48, ;
"This Application Will Close - Function Form INIT")
FLibPoxyFaultFound=.T.
EXIT
ENDIF
IF NOT CURSORSETPROP("KeyFieldList",FIELD(1,FLibCursorName) + ;
",TimeStamp",FLibCursorName)
MESSAGEBOX("Developer Message-: " + CHR(13) + CHR(13) + ;
"Unable to set KeyFieldList property in cursor " + ;
UPPER(FLibCursorName) + ".", 48, ;
"This Application Will Close - Function Form INIT")
FLibPoxyFaultFound=.T.
EXIT
ENDIF
* WhereType is for remote tables.
IF NOT CURSORSETPROP("WhereType",4,FLibCursorName)
MESSAGEBOX("Developer Message-: " + CHR(13) + CHR(13) + ;
"Unable to set WhereType property in cursor " + ;
UPPER(FLibCursorName) + ".", 48, ;
"This Application Will Close - Function Form INIT")
FLibPoxyFaultFound=.T.
EXIT
ENDIF
ENDIF
ENDFOR

SELECT (FLibCurrArea)
RELEASE FLibaVIDE

IF FLibPoxyFaultFound
SET EXCLUSIVE ON
SET SYSMENU TO DEFAULT
CANCEL
ENDIF


******************************
This all seems to work for me, although I do have to get
to grips with remote views in the future.

Your save routines should take into account whether the record
is new or not. If Recno() < 0, then all fields, including DBKey
should be updated. If a record being ammended, then use CursorSetProp
to remove the DBKey from the updatable field list before the save (just
a nicety). Put it back in after your TableUpdate.

Don't forget to set form to Private DataEnvironment.

You'll have to beautify these snippets, what you see here
is not as tidy as I posted.


I hope not too many people pick holes in my code.

Keith
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform