【问题标题】:Firemonkey StringGrid wont send back data to Snapserver under androidFiremonkey StringGrid不会在android下将数据发送回Snapserver
【发布时间】:2017-12-19 07:44:02
【问题描述】:

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

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

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

问候塔马斯

这是我的 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;

【问题讨论】:

    标签: android firemonkey delphi-xe5 stringgrid


    【解决方案1】:

    设置OnPostError, OnReconcileError,查看post过程中是否出现错误。 还要注意文档:

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

    【讨论】:

    • 我猜问题是我设置为 -1 的 0 现在一切正常
    猜你喜欢
    • 2015-08-05
    • 1970-01-01
    • 2012-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-29
    • 2012-07-11
    • 2021-03-14
    相关资源
    最近更新 更多