Search code examples
androidfiremonkeydelphi-xe5stringgrid

Firemonkey StringGrid wont send back data to Snapserver under android


I'm developing an android app in FM, NO BINDING(slow etc), I manually fill the data into string grid and manual update the records. The compiled 32-bit app works well but under android it wont UPDATE the records. Its communicate over DataSnap server everything is good under 32-bit.

Do You have any idea why wont update the records under android.

UPDATE (but its under testing): I dont know what was the problem yesterday but its working today, the only one thing what i changed is the ClientDataSet1.ApplyUpdates(0); to ClientDataSet1.ApplyUpdates(-1);

Regards Tamas

Here is my StringGrid insert code:

var
  ir: integer;
  cr, cc: integer;
begin
  ClientDataSet1.First;
  ir := 0;

  for cc := 0 to Grid_term.RowCount do
  begin
    for cr := 0 to Grid_term.ColumnCount do
    begin
      Grid_term.Cells[cc, cr] := '';
    end;
  end;

  while not ClientDataSet1.Eof do
  begin
    Grid_term.Cells[0, ir] := IntToStr(ClientDataSet1.FieldByName('torzs_id').AsInteger);
    Grid_term.Cells[1, ir] := ClientDataSet1.FieldByName('torzs_nev').AsString;
    Grid_term.Cells[2, ir] := IntToStr(ClientDataSet1.FieldByName('muszak_id').AsInteger);
    Grid_term.Cells[3, ir] := ClientDataSet1.FieldByName('gep_nev').AsString;
    Grid_term.Cells[4, ir] := ClientDataSet1.FieldByName('alkatresz_nev').AsString;
    Grid_term.Cells[5, ir] := IntToStr(ClientDataSet1.FieldByName('db_alkatresz_jo').AsInteger);
    Grid_term.Cells[6, ir] := IntToStr(ClientDataSet1.FieldByName('db_alkatresz_as').AsInteger);
    Grid_term.Cells[7, ir] := IntToStr(ClientDataSet1.FieldByName('db_alkatresz_ms').AsInteger);
    Grid_term.Cells[8, ir] := IntToStr(ClientDataSet1.FieldByName('A_szercsere').AsInteger);
    Grid_term.Cells[9, ir] := IntToStr(ClientDataSet1.FieldByName('A_beallitas').AsInteger);
    Grid_term.Cells[10, ir] := IntToStr(ClientDataSet1.FieldByName('A_karbantartas').AsInteger);
    Grid_term.Cells[11, ir] := IntToStr(ClientDataSet1.FieldByName('A_ghiba').AsInteger);
    Grid_term.Cells[12, ir] := IntToStr(ClientDataSet1.FieldByName('A_keszjavit').AsInteger);
    Grid_term.Cells[13, ir] := IntToStr(ClientDataSet1.FieldByName('A_technpro').AsInteger);
    Grid_term.Cells[14, ir] := IntToStr(ClientDataSet1.FieldByName('A_anyaghiany').AsInteger);
    Grid_term.Cells[15, ir] := IntToStr(ClientDataSet1.FieldByName('A_Egyeb').AsInteger);
    Grid_term.Cells[16, ir] := IntToStr(ClientDataSet1.FieldByName('ID').AsInteger);
    ir := ir + 1;
    ClientDataSet1.Next;
  end;

And here is the update code:

var
  ir: integer;
begin
  ClientDataSet1.First;
  ir := 0;
 // ClientDataSet1.
  while not ClientDataSet1.Eof do
  begin
    ClientDataSet1.Edit;
  {  ClientDataSet1.FieldByName('torzs_id').AsInteger := StrToInt(Grid_term.Cells[0, ir]);
    ClientDataSet1.FieldByName('torzs_nev').AsString := Grid_term.Cells[1, ir];
    ClientDataSet1.FieldByName('muszak_id').AsInteger := StrToInt(Grid_term.Cells[2, ir]);
    ClientDataSet1.FieldByName('gep_nev').AsString := Grid_term.Cells[3, ir];
    ClientDataSet1.FieldByName('alkatresz_nev').AsString := Grid_term.Cells[4, ir]; }
    ClientDataSet1.FieldByName('db_alkatresz_jo').AsInteger := StrToInt(Grid_term.Cells[5, ir]);
    ClientDataSet1.FieldByName('db_alkatresz_as').AsInteger := StrToInt(Grid_term.Cells[6, ir]);
    ClientDataSet1.FieldByName('db_alkatresz_ms').AsInteger := StrToInt(Grid_term.Cells[7, ir]);
    ClientDataSet1.FieldByName('A_szercsere').AsInteger := StrToInt(Grid_term.Cells[8, ir]);
    ClientDataSet1.FieldByName('A_beallitas').AsInteger := StrToInt(Grid_term.Cells[9, ir]);
    ClientDataSet1.FieldByName('A_karbantartas').AsInteger := StrToInt(Grid_term.Cells[10, ir]);
    ClientDataSet1.FieldByName('A_ghiba').AsInteger := StrToInt(Grid_term.Cells[11, ir]);
    ClientDataSet1.FieldByName('A_keszjavit').AsInteger := StrToInt(Grid_term.Cells[12, ir]);
    ClientDataSet1.FieldByName('A_technpro').AsInteger := StrToInt(Grid_term.Cells[13, ir]);
    ClientDataSet1.FieldByName('A_anyaghiany').AsInteger := StrToInt(Grid_term.Cells[14, ir]);
    ClientDataSet1.FieldByName('A_Egyeb').AsInteger := StrToInt(Grid_term.Cells[15, ir]);
   // ClientDataSet1.FieldByName('ID').AsInteger := StrToInt(Grid_term.Cells[16, ir]);
    ir := ir + 1;

    ClientDataSet1.Post;
    ClientDataSet1.Next;
  end;
  ClientDataSet1.ApplyUpdates(0);
  ClientDataSet1.Refresh;

Solution

  • Set OnPostError, OnReconcileError to see if there any errors occurring during the post. Also pay attention to the documentation:

    ApplyUpdates returns the number of errors it encountered. Based on this return value and the setting of MaxErrors, successfully applied records are removed from the client dataset's change log. If the update process is aborted before all updates are applied, any unapplied updates remain in the change log.