Apparently, in order to retrieve a return value, I first need to use the "adCmdStoredProc" CommandType, then set up a Parameter object, append that param. object to the Command object's parameter collection and then execute the command at which time the Parameter(0) object should contain the return value. the problem is, I can't get the stored procedure command type (adCmdStoredProc) to work when calling the vfp stored procedure. Instead I get the Ole error "Unrecognized Command Verb"
So, either this CommandType is simply not valid when the data source is a VFP dbc, or I am missing something in the CommandText. Here's the exact code I have:
*** Begin *****
#INCLUDE "C:\Program Files\Microsoft Visual Studio\Vfp98\VFPCOM\adovfp.h"
oCN=CREATEOBJECT('ADODB.Connection')
oCN.ConnectionString='Provider=VFPOLEDB.1;Data Source=c:\kba\admindata\kba_data.dbc'
oCN.Open()
oRS=CREATEOBJECT('ADODB.RecordSet')
oRS.ActiveConnection=oCN
oRS.Open('SELECT * FROM TASK')
oCM=CREATEOBJECT('ADODB.Command')
oCM.ActiveConnection=oCN
oCM.CommandText='SP_TEST'
oCM.CommandType=adCmdStoredProc
oPM=oCM.CreateParameter("Return",adInteger,adParamReturnValue,0,0)
oCM.Parameters.Append(oPM)
oCM.Execute()
? oCM.Parameters(0).Value
**** End *****
And the SP in the database is simple:
FUNCTION SP_TEST
RETURN 9
BTW, I tried several different variations of the CommandText, including SP_TEST(). When I change the CommandType to adCmdText, I don't get any errors, but the return value is always .NULL.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only