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

问题描述 投票:1回答:1

我正在开发一个FM应用程序,没有绑定(慢等),我手动将数据填充到字符串网格和手动更新记录。编译后的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个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.