Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 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: 104481 # Views: 4 # Ratings: 1
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Wednesday, August 16, 2006 10:37:21 PM         
   


> 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



Hi,
Just my 2 cents worth. I do not use remote view at all with SQL-Server
but will use only the SQLEXEC() calls.
If you are worried about such a thing as a duplicate primary key you can
issue a select statement to see if the key exists prior to updating
the SQL-Server backend. However, your code although I have not tested it looks OK.. but I am unsure of what you are doing in your error trapping?
You need to add a MessageBox popup to advise that the user entered in
a duplicate entry.
Pete from the Great White North. (Only in Canada, ay.) Over and Out ...

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