Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning values from an SQL stored procedure
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00930255
Message ID:
00930267
Vues:
15
Hi Derek:

instead of
return (@lnLoginID)
do it like
select @lnLoginID as loginid
and in the SQLExec command, put the result set into a cursor like
=SQLExec(lnConnection, "execute ApplicationLoginInsert1 ?lcParam1", "Curlogin")
Curlogin.LoginID will contain the login ID returned by the stored procedure.

Hope this helps...

>Hi

>I run the following code, from within VFP, to perform an SQL insert within SQL Server:
lcParam1 = 'MyPCName'
=SQLExec(lnConnection, "execute ApplicationLoginInsert1 ?lcParam1")
>The corresponding SQL stored procedure, called ApplicationLoginInsert1, looks like this:
CREATE Procedure ApplicationLoginInsert1 @lcParam1 char(128)
AS
insert into ApplicationLogin (Login_PC) values (@lcParam1)
declare @lnLoginID int
exec @lnLoginID = Version1.dbo.ApplicationLogin.Login_ID
return (@lnLoginID)
GO
>These procedures work fine, in that a new record is indeed inserted into my SQL Server table. The idea behind @lnLoginID is to return the value of ApplicationLogin.Login_ID, the newly created record, back to VFP. However, all that's ever returned from SQL Server is either 1 or -1.

>How would I return the actual value of the aforementioned field back to VFP, i.e. the newly created record ID?

>Regards

>Derek
Bernard L. Omiple
VFP, SQL Server, Crystal Reports
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform