Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I refresh only one row of a updateable cursor ?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00781497
Message ID:
00781890
Views:
20
>Hi all !
>I'd like to refresh (after detecting update conflict) only one row of a cursor created and filled using cursoradater connected through ODBC to SQLServer backend. How can I do that ?
>Thanks in advance.

Hi Jozef,

Unfortunately, CursorAdapter doesn't have this functionality, but for ODBC data source you can use REFRESH function (it works for native data source too). There is one trick - you have to set Tables, KeyFieldList, UpdatableFieldList and UpdateNameList properties using CURSORSETPROP function.
CLOSE DATABASES all
CLEAR

con=SQLCONNECT("alekseyt5")
?con

TEXT TO cSql NOSHOW
	create table #test (f1 int,f2 varchar(10))
	insert into #test values (1,'1111')
	insert into #test values (2,'2222')
	insert into #test values (3,'3333')
ENDTEXT

?SQLEXEC(con,cSql)

oCA=CREATEOBJECT("CursorAdapter")
oCA.DataSourceType="ODBC"
oCA.DataSource=con
oCA.SelectCmd="select * from #test"
oCA.Tables = "#test"
oCA.UpdatableFieldList="f1,f2"
oCA.KeyFieldList="f1"
oCA.UpdateNameList="f1 #test.f1, f2 #test.f2"
?oCA.CursorFill()

GO 2
?"Original field values-",f1,f2

?SQLEXEC(con,"update #test set f2='44444' where f1=2")

TRY
	REFRESH()
CATCH
	? "REFRESH() failed as expected."
ENDTRY	
?
?"Set properties to make REFRESH work"
CURSORSETPROP("Tables", oCA.Tables)
CURSORSETPROP("UpdatableFieldList",oCA.UpdatableFieldList)
CURSORSETPROP("KeyFieldList",oCA.KeyFieldList)
CURSORSETPROP("UpdateNameList",oCA.UpdateNameList)

REFRESH()
?"Refreshed field values-",f1,f2

USE
SQLDISCONNECT(con)
return
Thanks,
Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform