Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Borislav Borissov
  Where is Borislav Borissov?
 Sofia
 Bulgaria
 Borislav Borissov
 To: Nilson Rishi
  Where is Nilson Rishi?
 Bangkok
 Thailand
 Nilson Rishi
 Tags
Subject: RE: detect update conflicts in SQL Server
Thread ID: 104131 Message ID: 104505 # Views: 4 # Ratings: 1
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, August 17, 2006 9:35:47 AM         
   


> If I use remote views, if TABLEUPDATE(.T.,.F.) returns .F., a update conflict has occured.
> But how to do it with SPT SQLExec(lnhdl,"UPDATE customer SET last_name = 'Rishi'")? My logic below is ok?
>
> lnResult=SQLExec(lnhdl,"UPDATE customer SET last_name = 'Rishi'")
> IF lnResult != 1 && SPT failed, because of any reasons such as update conflict,constraints violated, etc.
> SQLRollback(lnhdl)
> AERROR(amyError)
> DO CASE
> CASE amyError(1,5)=the_error_number_for_update_conflict_on_SQL_server && the SPT failure reason is a update conflict
> OTHERWISE
> ENDCASE
> ELSE
> SQLCommit(lnhdl)
> ENDIF
>
> Am I right?
> Regards,
> Nilson


I am strong supporter of CursorAdapters :-)
I have one note for your code. Put AERROR() Before Rollback. That is becuase SQL Server @@ERROR is reset at every command you send to SQL Server.
IF lnResult < 0
   AERROR(amyError)
   SQLRollback(lnhdl)
....


Borislav Borissov



ENTIRE THREAD

detect update conflicts in SQL Server Posted by Nilson Rishi @ 8/11/2006 6:30:49 PM
RE: detect update conflicts in SQL Server Posted by Pete Sass @ 8/16/2006 10:37:21 PM
RE: detect update conflicts in SQL Server Posted by Borislav Borissov @ 8/17/2006 9:35:47 AM
RE: detect update conflicts in SQL Server Posted by Nilson Rishi @ 9/18/2006 6:09:35 AM
RE: detect update conflicts in SQL Server Posted by Borislav Borissov @ 9/18/2006 8:59:27 AM
RE: detect update conflicts in SQL Server Posted by Pete Sass @ 9/23/2006 12:13:56 AM
RE: detect update conflicts in SQL Server Posted by Nilson Rishi @ 9/24/2006 4:46:08 PM