Home > Back-end >  For help: a problem the Dataset not confuse a lot of people in the edit or insert mode
For help: a problem the Dataset not confuse a lot of people in the edit or insert mode

Time:10-01

Add the following code in the Button click event, empty ClientDataSet2,
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 change

CodePudding user response:

Look at your ClientDataSet2 AfterInsert, whether beforePost event wrote what code, led off debugging see can not first ~

CodePudding user response:

reference 1st floor gallardo response:
should be in AfterInsert or some other events have action, has led to the change of State after Append

refer to the second floor yangb0803 response:
look under your ClientDataSet2 AfterInsert, whether beforePost event wrote what code, led off debugging see can not first ~

No my ClientDataSet2 these two events are empty, nothing,

CodePudding user response:

With ClientDataSet2 do
The begin
Append.

Append and other in the same direction?
That is, the Compiler does not think is ClientDataSet2. Append?
Write directly ClientDataSet2. Append a try,
In the same way, might also don't correspond FieldByName ClientDataSet2,
Use ClientDataSet2 FieldByName try

CodePudding user response:

reference 4 floor frank_lee_cn response:
with ClientDataSet2 do
The begin
Append.

Append and other in the same direction?
That is, the Compiler does not think is ClientDataSet2. Append?
Write directly ClientDataSet2. Append a try,
In the same way, might also don't correspond FieldByName ClientDataSet2,
Try using ClientDataSet2. FieldByName

What do you mean may have a problem with do statement right?? I also tried to remove the with the do, writing those statements, alone or not, the headache is: this code line sometimes, sometimes an error, I write a small engineering test according to this form a separate, never at fault,

CodePudding user response:

Before operating the data operating status, to EDIT mode
  • Related