Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter refresh from stored procedure
Message
From
23/04/2005 04:04:09
 
 
To
22/04/2005 12:05:04
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01007506
Message ID:
01007757
Views:
32
This message has been marked as the solution to the initial question of the thread.
Hi David,

CursorAdapter.InsertCmd is not supposed to return any RecordSets. If any RecordSets are returned, CursorAdapter simply discards them and the only way for you to get them is to execute the command manually and process any RecordSets returned by the command. To achieve that you should:
1. Set InsertCmdDataSourceType="Native"
2. Set InsertCmd to a UDF or a method call, which will execute stored procedure using InsertCmdDataSource and will process RecordSets.

However, there are other ways to refresh field(s) during TABLEUPDATE:
1. You can bind fields to output parameters and/or to the result of stored procedure (an example is below).
CLEAR

LOCAL oConn as ADODB.Connection, oRS as ADODB.Recordset, oCom as ADODB.Command

oConn=CREATEOBJECT("ADODB.Connection")
oConn.Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Data Source=(local)")

oConn.Execute("create table #test (f1 int IDENTITY)")
oConn.Execute("create procedure #test_ins_1 @f1 int OUT as "+;
			  " insert into #test DEFAULT VALUES "+;
			  " select @f1=SCOPE_IDENTITY()")
oConn.Execute("create procedure #test_ins_2 as "+;
			  " insert into #test DEFAULT VALUES "+;
			  " return SCOPE_IDENTITY()")

oCom = CREATEOBJECT("Adodb.Command")
oCom.ActiveConnection = oConn

oRS = CREATEOBJECT("Adodb.Recordset")
oRS.ActiveConnection = oConn

LOCAL oCA as CursorAdapter

oCA=CREATEOBJECT("CursorAdapter")
oCA.Alias="test"
oCA.DataSourceType="ADO"
oCA.DataSource=oRS
oCA.SelectCmd="select * from #test"
oCA.InsertCmdDataSourceType="ADO"
oCA.InsertCmdDataSource=oCom
oCA.InsertCmd="EXEC #test_ins_1 ?@test.f1 OUT"

?oCA.CursorFill()

APPEND BLANK
APPEND BLANK
APPEND BLANK

oCA.InsertCmd="EXEC ?@test.f1 = #test_ins_2"
APPEND BLANK
APPEND BLANK
APPEND BLANK

LIST

?oCA.CursorRefresh()
LIST
USE

RETURN 
2. Or you can use InsertCmdRefreshCmd to refresh some fields after InsertCmd has been executed.

There is no need to use RecordRefresh() method to refresh auto-increment field, but, if you really want to, it can be done. It will be somewhat similar to using InsertCmdRefreshCmd property.

Thanks,
Aleksey.


>Hello,
>
>I am using a CursorAdapter with an ADO DataSource and a stored procedure as InsertCmd, which returns the value of the database auto-increment field. I would like this field to be refreshed with the CursorAdapter RecordRefresh() method after the TABLEUPDATE() command is issued, but I don't see any way to do it.
>
>From the VFP help I understood that if a record has been inserted, the TABLEUPDATE() command will issue an Execute() on the InsertCmdDataSource, which is a ADODB.Command object. This Execute() method returns a RecordSet which contains the return value of the procedure, but where can I catch this RecordSet ?
>
>Thank you very much if you can help me on this matter.
>
>Regards,
>
>David
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform