Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with SELECT statement
Message
De
27/11/1997 23:48:33
 
 
À
27/11/1997 23:17:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00062664
Message ID:
00062669
Vues:
25
>!Warning: This is a NEWBIE question!
>
>Can anyone show me the proper way to embed an SQL statement - specifically the SELECT statement - into an event (in my case the click event of a command button)
>
>Actually, I wanted to retrieve a login_id from my table, called tbl_staff, if the input login_id supplied by the user, in this case the login_id entered into a text box called cLoginID, exists in the table.
>
>I tried
>
>(line 1) =SELECT login_id;
>(line 2) FROM tbl_staff;
>(line 3) INTO cString2;
>(line 4) WHERE login_id = ThisForm.cLoginID.value
>
>At Line 3, i wanted to store the return value into a variable so that i can check the variable to see whether it's a valid login_id based on whether the SELECT statement was successful or not

You don't need to do a SELECT to get this value.
You need to have an index on the login_id field and:
IF SEEK(ThisForm.cLoginID.value, "tbl_staff", "login_id")
   *-- The login id exists.
ELSE
   *-- The login id doesn't exist.
ENDIF

or, if you don't want to have an index on login_id (probably this is not a big table):

SELECT tbl_staff
LOCATE FOR tbl_staff.login_id = ThisForm.cLoginID.value
IF FOUND()
   *-- The login id exists.
ELSE
   *-- The login id doesn't exist.
ENDIF
Vlad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform