Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Paul Brown
  
 York
 
 Paul Brown
 To: Roman Yedokov
  Where is Roman Yedokov?
 Milburn
 New Jersey - United States
 Roman Yedokov
 Tags
Subject: RE: Getting SP return value through ADO
Thread ID: 78451 Message ID: 78477 # Views: 1 # Ratings: 0
Version: Visual FoxPro 8 Category: ODBC, ADO and OLEDB
Date: Tuesday, October 04, 2005 10:18:09 AM         
   


The Execute method returns a recordset object. You just need to iterate the fields to get the values:
FOR EACH loField IN lvRetVal.Fields
	? loField.Name
	? loField.Value
ENDFOR


HTH
Paul


> There is a SQL stored procedure as simple as this:
> CREATE PROCEDURE sp_test AS
> RETURN 33
> GO
>
> I'm trying to get the return value from VFP using ADO:
> LOCAL loConn AS ADODB.Connection, lvRetVal
> CLEAR
> loConn = CREATEOBJECT("ADODB.Connection")
> loConn.ConnectionString = GetConnString()
> loConn.Open()
>
> * 1 - Execute
> lvRetVal = loConn.Execute("sp_Test")
> ?VARTYPE(lvRetVal), lvRetVal &&Shows O (Object)
>
> * 2 - as a native method
> lvRetVal = loConn.sp_Test() &&Crashes
> ?VARTYPE(lvRetVal), lvRetVal
>
> loConn.Close()
>
> First call returns an object and as I can see from debugger it's a recordset. How would I get the number SP actually returns?
>
> Second call is supposed to be working according to Microsoft. I'm getting an error:
> "OLE IDispatch exception code 0 from ADODB.Connection: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another..."
> But there is no arguments. What does it want from me?
>
> Thanks
> Roman Yedokov
> MFP


ENTIRE THREAD

Getting SP return value through ADO Posted by Roman Yedokov @ 10/3/2005 10:23:32 PM
RE: Getting SP return value through ADO Posted by Paul Brown @ 10/4/2005 10:18:09 AM