Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP/ADO/SQL stored procedure syntax
Message
From
06/10/2005 11:43:40
 
 
To
06/10/2005 11:18:29
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01056781
Message ID:
01056798
Views:
50
I use the ADO Command object to do this.
*  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 adDBTimeStamp	135
#DEFINE adParamInput	1
#DEFINE adParamOutput	2
#DEFINE adCmdStoredProc	4
#DEFINE adUseClient	3
#DEFINE adExecuteNoRecords	128

LOCAL lnIn, lnOut, loCmd, loADOCmd, loADOPara

lnIn=15
*&
loADOCmd = CREATEOBJECT("ADODB.Command")
loADOCmd.ActiveConnection = oConn
loADOCmd.CommandText = "usp_test"
loADOCmd.CommandType = adCmdStoredProc
loADOPara = loADOCmd.CreateParameter("@intIn", adInteger, adParamInput, , lnIn)
loADOCmd.Parameters.Append(loADOPara)
loADOPara = loADOCmd.CreateParameter("@intOut", adInteger, adParamOutput)
loADOCmd.Parameters.Append(loADOPara)
loADOCmd.Execute(,,adExecuteNoRecords)
*&
lnOut = loADOCmd.Parameters("@intOut").Value
>Assuming we have the following SQL stored procedure:
>
>CREATE PROCEDURE usp_test
>	@Number	INT,
>	@NewNumber INT OUTPUT
>AS
>SET @NewNumber = @Number + 3
>RETURN @NewNumber
>GO
>
>
>In VFP we have valid ADODB.Connection object oConn and some variables. I want to use connection's Execute method:
>
>LOCAL lnIn AS Integer, lnOut AS Integer, lnReturn AS Integer
>lnIn=15
>oConn.Execute("What?")
>
>
>What would be the correct syntax for:
>a) getting procedure's return value?
>b) getting procedure's output parameter?
>
>Microsoft claims that it is possible to execute a stored procedure as a native method of a Connection object. Something like this:
>
>lnReturn = oConn.usp_test(lnIn, @lnOut)
>
>I has not been able to get it working. Has anyone?
Previous
Reply
Map
View

Click here to load this message in the networking platform