Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Remote View with IDENTITY field
Message
 
To
09/04/2007 18:18:30
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01213531
Message ID:
01213765
Views:
21
Thanks very much Mark. Can't get the SETFLDSTATE() approach to work in VFP6 but the CURSORSETPROP("SendUpdates",.F.) approach worked.

>I retested everything and was able to replicate the error in vfp 8.
>
>But I am able to get around this by turning off sendupdates, updating the local tables "identity" field, doing a tableupdate and then turning sendupdates back on. You might play with this to see if you can get it to work.
>
>Incidentally, using setfldstate() also works for me in vfp 8:
>append blank, tableupdate(), replace identity fields, setfldstate(), update a different field and tableupdate() works.
>
>Hope this helps.
>
>>A VFP version issue is what I was beginning to think as well. I had a similar issue in the past where AD user and password authentication code would work in VFP7 and above but errored in VFP6.
>>
>>It may not have any bearing but I'm grasping at any straw now. When you tested the code in 8 and 9, what data type was the IDENTITY field on SQL Server and what was the data type in the remote view? Mine are both Integer, however I noticed that lastpk.lastpk was N(20)
>>
>>>I am not sure. I tried code similar to your code in vfp 8 and 9 and it works (and I don't get any errors). I don't have VFP 6 installed, so I can't test so I am not sure if it is a version difference or something is setup differently.
>>>
>>>Similar to my prior post, try to trick fox into thinking an update is not needed:
>>>
>>>* turn off sending updates to server and update the identity field
>>>CURSORSETPROP("SendUpdates",.F.)
>>>replace identity_field with x
>>>
>>>* issue a table update, which shouldn't send the update because sendupdates is turned off
>>>TABLEUPDATE()
>>>
>>>* reset sendupdates
>>>CURSORSETPROP("SendUpdates",.T.)
>>>
>>>
>>>>Interesting thought Mark. After replace sqlupdtuid with lastpk.lastpk, I added SETFLDSTATE("SQLUPDTUID", 1).
>>>>
>>>>Unfortunately, the same Update conflict occurs. Any other thoughts?
>>>>
>>>>>Maybe use SETFLDSTATE() to reset the fields updated status.
>>>>>
>>>>>>>>I have an RV on a SQL Server table with an IDENTITY (int) field. After an add, I am trying to get the IDENTITY fields value to stuff into the RV for subsequent possible edits. I do this fine but the next tableupdate(1) always returns an Update Conflict. Is what I am trying to do possible? If so, any suggestions on what I'm doing wrong? Example of code below:
>>>>>>>>
>>>>>>>>append blank
>>>>>>>>
>>>>>>>>(... populate all the fields, except sqlupdtuid (IDENTITY field) which is the key)
>>>>>>>>
>>>>>>>>=tableupdate(1) && This is successful
>>>>>>>>
>>>>>>>>lnHandle = CURSORGETPROP("ConnectHandle", "CDMTESTTABLE")
>>>>>>>>=SQLEXEC(lnHandle, "SELECT @@IDENTITY AS LastPK", "LastPK")
>>>>>>>>select cdmtesttable
>>>>>>>>replace sqlupdtuid with lastpk.lastpk
>>>>>>>>
>>>>>>>>=tableupdate(1) && This fails with Update Conflict
>>>>>>>
>>>>>>>Do you have row or table buffering on your RV? Your idea cannot work for table buffering.
>>>>>>>Btw, you may always Requery() your view to get most recent data, including identity field. Also, you better use @@SCOPE_IDENTITY instead of @@IDENTITY on SQL-Server side.
>>>>>>
>>>>>>Thanks for the reply Ed. I tried optimistic record buffering on the RV and it didn't work either. Same Update Conflict error. As for REQUERY(), I'd prefer to avoid bringing the entire table down each time an add is done.
>>>>>>
>>>>>>Any other thoughts?
Colin Magee
Team Leader, Systems Development
Metroland Media Group Ltd.
Mississauga, Ontario, Canada

cmagee@metroland.com

Never mistake having a career with having a life.
Previous
Reply
Map
View

Click here to load this message in the networking platform