Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Good code in my Load Event?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00590717
Message ID:
00590735
Vues:
16
There are settings which are "Private". So if you have a form with a private datasession, you need to set these settings in the load event.
Also the DBC is private. If you are in a private datasession you need to open the database.
I never set the path to the database location, so the database cannot be found unless I open it. This prevents me from doing mistakes.

I have a class that has a method called SetPrivateSettings. I instantiate this class in the load event of each form. So the load looks like:
IF !DODEFAULT()
RETURN .F.
ENDIF
WITH THIS
.NEWOBJECT("oUtils","Utils","Utils")
.oUtils.SetPrivateSettings()
ENDWITH

All the other settings which are not private but public in scope are set in the application object at the startup of the application.

HTH.


>Hi - I just wanted to get some advice really - I use this code in the LOAD of all my forms where there is data involved...
>
>if !dbused('gen_data')
>open database gen_data shared
>endif
>
>set database to gen_data
>set date british
>set exclusive off
>set multilocks on
>set exact on
>
>
>* open views
>
>if !used('v_customers')
>use v_customers shared in 0 nodata
>endif
>
>I have a couple of questions...
>
>1. Should I be opening the database at the start of application rather than attempting it whenever I open a new form?
>
>2. Is the order that I am doing things correct? ie. open and set database then set exclusive off?
>
>3. Any other comments?
Christian Isberner
Software Consultant
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform