Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP/ADO/SQL stored procedure syntax
Message
 
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:
01056822
Views:
59
Try this:
LPARAMETERS cConnString As String ,cComando As String, lcParam As String 

	oConn 	 = CREATEOBJECT("ADODB.Connection")
	oComando = CREATEOBJECT("ADODB.Command")
	oRS 	 = CREATEOBJECT("ADODB.Recordset")

	oConn.Connectionstring = cConnString
	oConn.Open

	IF TYPE("lcParam")="U"
		lcParam=""
	ENDIF 

        *--- cComando = name of the desired procedure
        *--- lcParam = string with parameters

	oComando.CommandText= cComando+" "+lcParam
	oComando.ActiveConnection=oConn
	
	oRS = oComando.Execute()
	oConn = Null
	oComando = Null 
RETURN oRS
>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?
I'm a mixture of Albert Einstein and Arnold Schwarzenegger. The only trouble is that I got Einstein's body and Schwarzenegger's brain
Previous
Reply
Map
View

Click here to load this message in the networking platform