Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Safe Table Opening Code -How's This?
Message
De
26/10/2001 11:59:38
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00573683
Message ID:
00573706
Vues:
23
First of all, I would recommend programming for network access, even if only one person uses your application at the same time. After all, the considerations when accessing the same table from different form (with private DataSessions), or from two instances of the same form, are virtually the same as for network access.

As to the object, I was thinking about simplifying the closing of tables.

However, you might create an object (based on "Custom"), with custom properties and methods.

For instance:

Custom Property .cAlias (remembers the alias)

Method Init (Init receives parameters, and tries to open the table).

Custom Method SaveAll() (Does a TableUpdate, to save all records. Returns .T. or .F., depending on whether all records could be saved).

Method Destroy() (automatically invokes SaveAll(), and closes the table).

It is safer, I believe, to invoke .SaveAll() explicitly.

Hilmar.

>They are going to be methods in a public-scope "data activity object" class that I am instantiating at app startup. So I'd call TOpen() instead of using VFP's use command. Everything is happening on the local box (no shared network access). I just wanted to be sure I got the table open properly (in case I already have it open elsewhere, etc).
>
>What would you recommend in the Destroy() event to get every table tableupdate()'d etc?
>
>
>
>>What sort of safety do you want?
>>
>>If you use an object instead, you can save yourself the trouble of closing the table in code: the table is closed in the class'es Destroy() event. As soon as the object variable gets out of scope, Destroy() fires!
>>
>>However, there is no need to close tables if you use the table in a form with a private DataEnvironment.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform