#1 2012-02-21 15:44:38

lele9
Member
Registered: 2011-10-28
Posts: 170

updatefrom server don't work?!

hi,
i m doing some test and i have this preblem.
after insert/update/delete of a record i return in the form where i display all record in a grid.
so i use updatefromserver to know if my grid need a refresh.
this works fine except if i delete the only one record (last).

   if not ControllerMain.Client.UpdateFromServer([Self.Elenco], NeedRefresh) then
   begin
      //raise exception    //HERE WHEN I DELETE LAST RECORD! WHY?
   end
   else
   begin 
        if NeedRefresh then
        begin
         // the client refresh all GUI about TSQLTestTable.
       
      end;
   end;

Thanks,
Emanuele

Offline

#2 2012-02-21 18:22:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,667
Website

Re: updatefrom server don't work?!

Is not UpdateFromServer() failing because the Self.Elenco was deleted?

When you delete a record, the TSQLDataBase.Lock() method will increase the server's InternalState so the refresh should be done.

Without more code to reproduce the issue, it is difficult to know what is wrong here.

Offline

#3 2012-02-21 18:35:02

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: updatefrom server don't work?!

hi ab,
Self.Elenco is a TSQLTableJSON created onCreate of datamodule, and free onDestroy so self.Elenco wasn't deleted.
if u need i can post the code for delete record...

Offline

#4 2012-02-21 19:08:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,667
Website

Re: updatefrom server don't work?!

yes please
smile

Perhaps you may step into TSQLRestClientURI.UpdateFromServer() with the debugger and see why it returns with result=false.

Offline

#5 2012-02-22 08:32:03

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: updatefrom server don't work?!

hi,
this is the portion of code for delete a record.

      if Application.MessageBox('Sei sicuro di voler eliminare il record?',
                                'CONFERMA', MB_YESNO + MB_ICONQUESTION) = IDYES then
      begin
         ControllerMain.Client.TransactionBegin(Self.Tabella);
         Try
         ControllerMain.Client.Delete(Self.Tabella, ID);
         
         ControllerMain.Client.Commit();
         Except
            on E: Exception do
            begin
               ControllerMain.Client.RollBack();
               Application.MessageBox(PWideChar('Errore durante l''eliminazione del record: ' +
                                       E.ClassName + #13#10 + E.Message),
                                       'ERRORE', MB_OK + MB_ICONERROR);
            end;
         End;
      end;

Offline

#6 2012-02-22 08:53:31

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: updatefrom server don't work?!

hi,
i step into update from server...
updatefrom server return false for a parsing error (return code 2).
i step also into ParseAndConvert.
i arrive at line 9973 repeat inc(P); if P^=#0 then exit; until P^='{'; // go to object beginning
then i have count 3 loop before exit.
loop 1 P^ = '['
loop 2 P^ = ']'
loop 3 P^ = #10

this can help u?
thanks,
Emanuele

Offline

#7 2012-02-23 11:54:10

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: updatefrom server don't work?!

hi ab,
any idea why i have this behavior?
thanks,
emanuele

Offline

#8 2012-02-23 13:09:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,667
Website

Re: updatefrom server don't work?!

Whats is the JSON content returned by the server, before parsing?

Offline

#9 2012-02-24 08:20:11

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: updatefrom server don't work?!

hi ab,
before parsing JSON is
'[]'#$A
that i think its right because the table is empty, but if i have error on parsing updatefromserver dont refresh self.elenco and i have an exception.
where i mistake?
thanks

Offline

#10 2012-02-27 09:00:23

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: updatefrom server don't work?!

hi ab,
have u any idea for my question?
can i help u in other way?
thanks,
Emanuele.

Offline

#11 2012-02-29 09:15:31

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: updatefrom server don't work?!

hi ab,
i know thats its just my problem but i need to understand why updatefromserver don't work for me...
have u any idea?
thanks,
Emanuele.

Offline

#12 2012-03-19 13:20:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,667
Website

Re: updatefrom server don't work?!

I've fixed TSQLRequest.Execute(JSON: TStream) method in SynSQLite3.pas.

It now allows field names at least, even with no data (as expected by TSQLRestClientURI.UpdateFromServer).
See http://synopse.info/fossil/info/f633312bdc

It should fix your issue.

Offline

Board footer

Powered by FluxBB