在 android 下,Firemonkey StringGrid 不会将数据发送回 Snapserver
Firemonkey StringGrid wont send back data to Snapserver under android
我正在 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;
设置OnPostError、OnReconcileError以查看post期间是否发生任何错误。
还要注意文档:
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.
我正在 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;
设置OnPostError、OnReconcileError以查看post期间是否发生任何错误。 还要注意文档:
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.