Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Writing to a new Table
Message
De
15/12/2009 20:09:43
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
15/12/2009 19:06:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01439105
Message ID:
01439273
Vues:
34
>hmm so I looked at your code I always read buffering was to protect data during updating never quite got that part .Also i dont really follow your save code....nor do i trust mine

I'll copy the save code again, for reference, and add some more comments.
* "Save" button
if not TableUpdate()
  local laError[1]
  aerror(laError)
  MessageBox("Error code: " + trans(laError(1)) + " - Error message: " + laError(2), 16, "Error saving data")
endif
TableUpdate() will try to save the record. It will return .T. if you can save, .F. if you can't. Here is a simpler version:
if not TableUpdate()
  MessageBox("Can't save for some reason.")
endif
However, you want to give the user more specific information about what went wrong. Some reasons why a TableUpdate() can fail is because a trigger failed (due to referential integrity, or some other rule that doesn't allow you to save changes), because the table is read-only, a field-level rule or a record-level rule is violated, you try to insert duplicate data (duplicate according to a primary or candidate index), and several others more.

If an error occurs, you collect information, with the function aerror(). The function collects information about the error to an array, which I called laError. This array has 5 elements, but only the first two are interesting in most cases: the error number, and the error message. This information is then shown as an error message, with the function MessageBox().

HTH,

Hilmar.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform