Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Extra records deleting
Message
De
31/01/2009 19:26:30
 
 
À
31/01/2009 18:26:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01378618
Message ID:
01378630
Vues:
8
>I'm using a command button to delete files in a table. The "invoice" to delete is entered into the textbox value. The command works and the file is deleted, except it will mark 1 to 5 additional files with it. The additional files deleted are not related to the text1.value.
>
>What am I missing?
>
>In the click command I have the following:
>
>CLOSE DATABASES
>
>USE order1
>
>DELETE from order1;
> WHERE thisform.text1.Value = order1.invoice

In addition to Borislav's comments:

- it may not be a good idea to use object properties in a SQL engine command. For sure, they don't work in UPDATE - SQL: see thread#1264672

- normal syntax in SQL is to have
... WHERE Column = Value

rather than 

... WHERE Value = Column
I seem to recall some issue with coding the latter way, but I can't find a reference here.

As a side note, for maintenance reasons I don't usually put much code in the events/methods of controls. For example, I would normally create a custom form method called, say, DeleteButtonClick().

The button's Click() method would contain:
=ThisForm.DeleteButtonClick( ThisForm.Text1.Value )

and the custom method would be something like:
* DeleteButtonClick()
LPARAMETERS ;
  tcInvoice

CLOSE DATABASES ALL

USE Order1

DELETE FROM Order1 ;
  WHERE Order1.Invoice == tcInvoice
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform