Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    7

    Unanswered: [ Visual FoxPro ] Updating a view ...

    I have read lots of things about this problem but i have found no solutions.

    Here is what i have already done in my code:

    Set MultiLocks ON

    CursorSetProp('Buffering',3,'vue1')

    DBSETPROP('vue1','View','Tables','table1')
    DBSETPROP('vue1','View','Tables','table2')

    DBSETPROP('vue1.idclient','Field','KeyField',.T.)

    DBSETPROP('vue1.idclient','Field','Updatable',.T.)
    DBSETPROP('vue1.nomclient','Field','Updatable',.T. )
    DBSETPROP('vue1.nomdep','Field','Updatable',.T.)

    DBSETPROP('vue1','View','SendUpdates',.T.)


    And here is my update code:

    dimension numd(1)
    numd[1]=0

    Select numdep from table2 where nomdep=m.valeur into array numd

    If numd[1]==0 and m.opened==1
    Select max(numdep)+1 from table2 into array numd
    Insert into table2 (numdep,nomdep) values (numd,m.valeur)
    endif


    if m.opened==1
    m.idclient=Val(m.idclient)
    Update table1 set numdep=numd where idclient=m.idclient
    &&Update vue1 set nomdep=m.valeur where idclient=m.idclient
    TableUpdate(0,.F.,'vue1')
    endif

    m.opened=0

    ThisForm.Grid1.Column1.ControlSource="vue1.idclien t"
    ThisForm.Grid1.Column2.ControlSource="vue1.nomclie nt"
    ThisForm.Grid1.Column3.ControlSource="vue1.nomdep"

    ThisForm.Refresh



    The problem is that my view is never updated while my tables are.
    I have also checked the Send Update property in the Update Tab

    Thank you for help

  2. #2
    Join Date
    Mar 2004
    Location
    Venice,Italy
    Posts
    20
    'SendUpdates' property is usefull only on remote view (with mssql server)
    I don't see the definition of the view; one thing: you use the view for grid visualization only?

  3. #3
    Join Date
    Apr 2004
    Posts
    7
    i use only a local view at the moment and show it in a grid.

    The user modify the tables by doubleclicking the fields of the grid.
    Then a box appears and ask him the new value and to press a "Validate" button.

    Actually, all works fine,except the fact that my tables are updated but my view isn't.

    I hope this can help

  4. #4
    Join Date
    Mar 2004
    Location
    Venice,Italy
    Posts
    20
    one solution is to use a cursor instead of a view, something like this:

    select * from table1 into cursor tmp_read nofilter
    afield(aStruct,"tmp_read")
    create cursor vue1 from array aStruct
    select vue1
    append from dbf("tmp_read")
    select tmp_read
    use

    without setting any property
    another one is to regenerate the view/cursor under the grid.
    however to refresh the grid the method "refresh" not work well: you have to do :
    ThisForm.Grid1.recordsource=ThisForm.Grid1.records ource

  5. #5
    Join Date
    Apr 2004
    Posts
    7
    ok, thanks a lot.
    I will try this today .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •