>>>Hi gang,
>>>
>>>Here's one for your collective gray matter...
>>>
>>>I have a VFP DBC with a stored procedure that SELECTs some information. I can, of course, return that information in a browse window or to a cursor in VFP by opening the DBC and issuing "DO MyProc" in the command window.
>>>
>>>QUESTION: How do I return that information to a CursorAdapter using the VFP OLEDB provider? Just placing the command "DO MyProc" in the SelectCmd property doesn't work (CursorFill returns false). I don't think it's the CA itself, since the same CA works fine if I populate SelectCmd with the direct query and don't use the call to the VFP sproc (which, of course, I can't do over the long term, since the CA is intended to have multiple instances which each call different sprocs in the VFP DBC, all returning different data sets).
>>>
>>>Any ideas would be *greatly* appreciated, folks...
>>>
>>>TIA,
>>
>>oRS=oConn.Execute('StoredProc(Parms)')
>>luRetVAl = oRS.fields(0).Value
>>Cetin
>
>Hi Cetin,
>
>That works perfectly when I'm using ADO objects. What I'm trying to do is find the correct syntax for the SelectCmd property of the CA to execute the proc and return the rowset when I fire the CursorFill().
>
>Also, I wasn't aware that the CA had Connection/Recordset objects that I could get to/mess with/query. Is this the case, and if so, how do I state the object reference (something like oCursorAdapter.ActiveConnection or somesuch)?
>
>Thanks,
>Evan
Hi Evan,
Actually I don't see a point for things like this to do using CursorFill. I tend to correlate with ADO.NET and normal call for this in .NET is 'ExecuteScalar' - not meaning ExecuteScalar was designed for doing this, but it works nice and fast returning only the first column of first row. However it can be done with CA.Cursorfill (at the end it's another RS and VFP names -or ADO- the field 'Return_Value').
AFAIK CA doesn't have implicit connection and recordset objects. You add references to connection/rs objects. At least that's how I did it up to date when setting DataSourceType to ADO.
FUNCTION StoredProcTest
LPARAMETERS p1,p2,p3,p4
RETURN TRANSFORM(p1)+CHR(13)+CHR(10)+;
TRANSFORM(p2)+CHR(13)+CHR(10)+;
TRANSFORM(p3)+CHR(13)+CHR(10)+;
TRANSFORM(p4)
endfunc
#Define VFPCONNECTION "Provider=VFPOLEDB.1;Data Source=c:\Path\testdata.dbc"
Clear
Local oCa As CursorAdapter
oCa = NewObject('caADO', VFPCONNECTION)
? oCa.CallStoredProc("StoredProcTest('hello',1,Date(),Sys(2015))")
oCa.BrowseTable("select * from customer")
Define Class caADO As CursorAdapter
Procedure Init
Lparameters tcConn
This.Alias ='myCa'
This.AddProperty('oConn', Newobject("ADODB.Connection"))
This.AddProperty('oRs', Newobject("ADODB.Recordset"))
This.oConn.ConnectionString = tcConn
This.oConn.Open()
This.oRS.ActiveConnection = This.oConn
This.DataSourceType = "ADO"
This.Datasource = This.oRS
Endproc
Procedure CallStoredProc
Lparameters tcStoredProc
This.SelectCmd = tcStoredProc
This.CursorFill()
Return myCa.Return_Value
Endproc
Procedure BrowseTable
Lparameters tcSQL
This.SelectCmd = tcSQL
This.CursorFill()
Endproc
Enddefine
Cetin