locked
Update conflict in cursor from view in vfp9 RRS feed

  • Question

  • Hi all,

    I use vfp9 sp2 and winxp.

    I use a local view as record source for a grid (type = 1 && alias):

    SELECT Students.id, Former.form, Students.nname, Students.lastname,;
     IIF(genderid=3,"M","F") AS gender, Students.onbus;
     FROM ;
       students ;
      INNER JOIN former ;
      ON Former.id = Students.formid;
     ORDER BY Former.orden, Students.nname
    
    DBSetProp(ThisView,"View","SendUpdates",.T.)
    DBSetProp(ThisView,"View","BatchUpdateCount",1)
    DBSetProp(ThisView,"View","CompareMemo",.T.)
    DBSetProp(ThisView,"View","FetchAsNeeded",.F.)
    DBSetProp(ThisView,"View","FetchMemo",.T.)
    DBSetProp(ThisView,"View","FetchSize",100)
    DBSetProp(ThisView,"View","MaxRecords",-1)
    DBSetProp(ThisView,"View","Prepared",.F.)
    DBSetProp(ThisView,"View","UpdateType",1)
    DBSetProp(ThisView,"View","UseMemoSize",255)
    DBSetProp(ThisView,"View","Tables","gis_data!students")
    DBSetProp(ThisView,"View","WhereType",3)
    
    DBSetProp(ThisView+".id","Field","DataType","I")
    DBSetProp(ThisView+".id","Field","UpdateName","gis_data!students.id")
    DBSetProp(ThisView+".id","Field","KeyField",.T.)
    DBSetProp(ThisView+".id","Field","Updatable",.F.)
    
    DBSetProp(ThisView+".form","Field","DataType","C(20)")
    DBSetProp(ThisView+".form","Field","UpdateName","gis_data!former.form")
    DBSetProp(ThisView+".form","Field","KeyField",.F.)
    DBSetProp(ThisView+".form","Field","Updatable",.F.)
    
    DBSetProp(ThisView+".nname","Field","DataType","C(200)")
    DBSetProp(ThisView+".nname","Field","UpdateName","gis_data!students.nname")
    DBSetProp(ThisView+".nname","Field","KeyField",.F.)
    DBSetProp(ThisView+".nname","Field","Updatable",.F.)
    
    DBSetProp(ThisView+".lastname","Field","DataType","C(200)")
    DBSetProp(ThisView+".lastname","Field","UpdateName","gis_data!students.lastname")
    DBSetProp(ThisView+".lastname","Field","KeyField",.F.)
    DBSetProp(ThisView+".lastname","Field","Updatable",.F.)
    
    DBSetProp(ThisView+".gender","Field","DataType","C(1)")
    DBSetProp(ThisView+".gender","Field","KeyField",.F.)
    DBSetProp(ThisView+".gender","Field","Updatable",.F.)
    
    DBSetProp(ThisView+".onbus","Field","DataType","L")
    DBSetProp(ThisView+".onbus","Field","UpdateName","gis_data!students.onbus")
    DBSetProp(ThisView+".onbus","Field","KeyField",.F.)
    DBSetProp(ThisView+".onbus","Field","Updatable",.T.)
    
    In it the init event for the form where the grid is I do:

    UPDATE view_addmany SET onbus = 0

    This sometimes gives the error message:

    Update conflict in cursor 'VIEW_ADDMANY'.

    At other times, with different databases, it works OK.

    How do I fix it? I have tried to give all relevant information, but since I am a newbie I may well be mistaken.

    Regards,

    Jan Nordgreen

     

    Sunday, August 1, 2010 3:44 PM

Answers

All replies

  • Today I tried to add some code just before the instruction

     

    UPDATE view_addmany SET onbus = 0

    Here is the code:

    SET MULTILOCKS ON
    lSuccess=CURSORSETPROP("Buffering", 5, "students")
    IF lSuccess = .T.
     =MESSAGEBOX("Operation successful!",0,"Operation Status")
    ELSE
     =MESSAGEBOX("Operation NOT successful!",0,"Operation Status")
    ENDIF
    lSuccess=CURSORSETPROP("Buffering", 5, "former")
    IF lSuccess = .T.
     =MESSAGEBOX("Operation successful!",0,"Operation Status")
    ELSE
     =MESSAGEBOX("Operation NOT successful!",0,"Operation Status")
    ENDIF
    TABLEUPDATE(1,.t.,'students')
    TABLEUPDATE(1,.t.,'former')
    Students and Former are the two tables in the view. Sadly, this did not help. It produced the same error message as before.

    Regards,

    Jan Nordgreen

     

    Monday, August 2, 2010 2:16 PM
  • Hi Jan,

    You can refer to the following link which has the similar problem with yours to get some information and workround(focus on the last two relies).

    http://www.dbmonster.com/Uwe/Forum.aspx/foxpro-forms/1066/data-environment-error

    And you can refer to the following link to get some useful information about Detecting and resolving update conflicts in VFP.

    http://weblogs.foxite.com/andykramek/archive/2006/02/18/1155.aspx

    Best regards,
    Alex Liang


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by damezumari Tuesday, December 27, 2011 12:12 PM
    Friday, August 6, 2010 6:13 AM
  • Hi all,

    Today I discovered that the problem was due to a table in the data environment. I thought it was empty! When I deleted the table from the data environment the problem disappeared!

    Problem solved.

    Regards,

    Jan Nordgreen

    • Marked as answer by damezumari Sunday, August 22, 2010 11:15 AM
    • Unmarked as answer by damezumari Tuesday, December 27, 2011 12:12 PM
    Sunday, August 22, 2010 11:15 AM