If not ClientDataSet2. Active then
ClientDataSet2. Active:=true;
ClientDataSet2. EmptyDataSet;
In the subsequent a loop to achieve the following code, to add data record ClientDataSet2,
With ClientDataSet2 do
The begin
If the not Active then the Active:=True;
Append.
FieldByName (' NUMBER '). Asstring:='5';//execution to this error: the Dataset not edit or in insert mode, delete the sentence, is reported for the next sentence this error,
FieldByName (' LINENO). Asstring:='432';
FieldByName (' BUSNO). Asstring:='213';
FieldByName (' STATION '). Asstring:='43';
FieldByName (" STATIONNAME). Asstring:='33'.
FieldByName (' AVERAGESPEED). Asstring:='23';
Post;
end;
//below is the test tracking code, attached to Append, up and down in the Append breakpoints, tracking found CanModify to true, ReadOnly to false, but it is strange that the State is always dsBrowse,
If CanModify
And (not ReadOnly) then
Showmessage (' Can ');
In case the State of
DsInactive: showmessage (");
DsBrowse: showmessage (");
DsEdit: showmessage (");
DsInsert: showmessage (");
DsSetKey: showmessage (");
DsCalcFields: showmessage (");
DsFilter: showmessage (");
DsNewValue: showmessage (");
DsOldValue: showmessage (");
DsCurValue: showmessage (");
DsBlockRead: showmessage (");
DsInternalCalc: showmessage (");
DsOpening: showmessage (");
end;
//this last also did not make clear, use the following method to solve, will Append (including Append) and Post (including Post) code to replace with the following code between the
X:='5';
Y:='432';
Z:='213';
W:='43';
Q:='33';
H:='23';
AppendRecord ([x, y, z, w, q, h]);
The building Lord really turn to the great god of all stripes in the BBS analysis to solve this problem,
CodePudding user response:
Should be have action in AfterInsert or some other event, lead to Append the State after have changeCodePudding user response:
Look at your ClientDataSet2 AfterInsert, whether beforePost event wrote what code, led off debugging see can not first ~CodePudding user response: