Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return of a stored procedure
Message
From
20/12/2002 10:32:19
 
 
To
20/12/2002 09:51:24
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00734869
Message ID:
00734896
Views:
15
This message has been marked as the solution to the initial question of the thread.
Frederico,

This is the way I deal with output parameters with ADO. HTH.
*  Contants used by ADO
#DEFINE adInteger		3
#DEFINE adCurrency		6
#DEFINE adDate			7
#DEFINE adBoolean		11
#DEFINE adChar			129
#DEFINE adNumeric		131
#DEFINE adVarChar		200
#DEFINE adParamInput		1
#DEFINE adParamOutput		2
#DEFINE adCmdStoredProc		4
#DEFINE adExecuteNoRecords	128



LOCAL loADOCmd, loADOParam, loADOConn
*&
*&  Connect to your SQL Server here.
loADOConn = CREATEOBJECT("ADODB.Connection")
*&
*&
*&
loADOCmd = CREATEOBJECT("ADODB.Command")
loADOCmd.ActiveConnection = loADOConn
*&
loADOCmd.CommandText = "Contador"
loADOCmd.CommandType = adCmdStoredProc
*&
loADOPara = loADOCmd.CreateParameter("@Valor1", adInteger, adParamInput, , 1)
loADOCmd.Parameters.Append(loADOParam)
*&
loADOPara = loADOCmd.CreateParameter("@Valor2", adInteger, adParamInput, , 2)
loADOCmd.Parameters.Append(loADOParam)
*&
loADOPara = loADOCmd.CreateParameter("@nRetorno", adInteger, adParamOutput)
loADOCmd.Parameters.Append(loADOParam)
*&
loADOCmd.Execute(,,adExecuteNoRecords)
lnRetorno = loADOCmd.Parameters("@nRetorno").Value
>hello *.*
>
>I'm working with SQL SERVER 2000 and VFP7, using ADO.
>I created a stored procedure with a return, like this:
>
>
>CREATE PROCEDURE Contador
>@Valor1 int,
>@Valor2 int,
>@nRetorno int output
>AS
>SET @nRetorno = @valor1 + @valor2
>
>If I run it from query analyser such as:
>
>
>declare @resposta int
>exec contador 1,2, @resposta output
>select @resposta
>
>It's run without problems, but how do I do to return the value to VFP ?
>If I do a select and run I can get the fields with this command:
>
>recordset.fields.("name_of_my_field").value
>or
>recordset.fields.(0).value
>
>But it don't run ok when I run the stored procedure. Why ?
>
>Thank you all!
Previous
Reply
Map
View

Click here to load this message in the networking platform