Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use Sql commands in Sql Server Procedure
Message
De
06/02/2005 05:54:36
 
 
À
06/02/2005 01:36:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
00984276
Message ID:
00984285
Vues:
19
Hi Abdulla,

This is a very basic example of what your stored procedure could look like. In your sample code, you specify a lookup value of '001' so I assume it is character and upto three characters in length, hence my specification of CHAR(3) for the input parameter value - you can adjust this to your needs.
CREATE PROCEDURE dbo.sp_EmpFind	(
		@EmpCode CHAR(3)
	)
AS
	SET NOCOUNT ON
        SELECT EmpCode, EmpName
        FROM   Employee
        WHERE  EmpCode = @EmpCode
When you execute this stored procedure, the procedure will either find a matching record or it will not. In any case it will either return an empty result set (if it did not find) or a result set containing a single record (if it did find), assuming there is only a single employee with an EmpCode of '001'. Assuming you call this sproc using SQL passthru, you will have likely specified a cursor name for the returned result set in your passthru call.
SQLEXEC(nConnection, "EXEC sp_EmpFind", "Cur1")
And now, your Fox code.
SELECT Cur1
IF RECCOUNT("Cur1") == 1
   * We have found our employee.
   m.cName = Cur1.EmpName
ELSE
   MESSAGEBOX("Invalid Code.")
ENDIF
Hope this helps.

Best
-=Gary
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform