delphi clientdataset Field 'amount' cannot be modified.
clientdataset 修改数据可能报错不让修改,如下:Field 'amount' cannot be modified.或Trying to modify read-only field.用下面的过程在clientdataset打开后 执行下,重新生成下clientdataset的字段属性即可,procedure SetDstAllFieldCanEdit(dstNm: TClien
·
clientdataset 修改数据可能报错不让修改,如下:
Field 'amount' cannot be modified.
或
Trying to modify read-only field.
用下面的过程在clientdataset打开后 执行下,重新生成下clientdataset的字段属性即可,
procedure SetDstAllFieldCanEdit(dstNm: TClientDataSet; AddFields: string = '');
vartmpDst: TClientDataSet;
I: Integer;
begin
tmpDst := TClientDataSet.Create(nil);
try
dstNm.DisableControls;
tmpDst.Data := dstNm.Data;
dstNm.Close;
dstNm.FieldDefs.Clear;
for I := 0 to tmpDst.FieldDefs.Count - 1 do
begin
with dstNm.FieldDefs.AddFieldDef do
begin
DataType := tmpDst.FieldDefs[I].DataType;
Size := tmpDst.FieldDefs[I].Size;
Name := tmpDst.FieldDefs[I].Name;
end;
end;
// CreateAttachColumns(dstNm,AddFields);
dstNm.CreateDataSet;
with tmpDst do
begin
First;
while not Eof do
begin
dstNm.Append;
for I := 0 to Fields.Count - 1 do
dstNm.Fields[I].Value := Fields[I].Value;
Next;
end;
end;
if dstNm.State in [dsInsert, dsEdit] then
dstNm.Post;
dstNm.MergeChangeLog;
finally
dstNm.EnableControls;
tmpDst.Free;
end;
end;
昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链
更多推荐



所有评论(0)