Firemonkey StringGrid不会将数据发送回android下的Snapserver

时间:2017-12-19 07:44:03

标签: android firemonkey delphi-xe5 stringgrid

我在FM中开发了一个Android应用程序,没有绑定(慢等),我手动将数据填充到字符串网格中并手动更新记录。 编译后的32位应用程序运行良好,但在android下它不会更新记录。 它通过DataSnap服务器进行通信,在32位下一切都很好。

你知道为什么不更新android下的记录。

更新(但正在测试中): 我不知道昨天的问题是什么,但它今天工作,我改变的唯一一件事就是ClientDataSet1.ApplyUpdates(0);到ClientDataSet1.ApplyUpdates(-1);

关心Tamas

这是我的StringGrid插入代码:

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;

这是更新代码:

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;

1 个答案:

答案 0 :(得分:0)

设置 OnPostError,OnReconcileError 以查看帖子中是否发生任何错误。 另外要注意文档:

  

ApplyUpdates返回遇到的错误数。基于此返回值和   设置MaxErrors,删除成功应用的记录   客户端数据集的更改日志。如果更新过程中止   在应用所有更新之前,任何未应用的更新仍保留在   改变日志。