03-03-2020, 09:12 AM
(This post was last modified: 03-03-2020, 09:14 AM by SorenJensen.)
I am a bit closer to finding the reason, I hope. Tests today gives ADOStoredProc error: Cannot persorm this operation on a closed dataset.
However, the dataset is not closed at the time of the call. I always use a structure like this:
dm := TApp3TDB.Create(nil);
try
dm.ADOSP1.ProcedureName := 'sp_CustomerGet';
dm.ADOSP1.Parameters.Refresh;
dm.ADOSP1.Parameters.ParamByName('@CustomerNo').value := CustomerNo;
dm.ADOSP1.Prepared := true;
try
dm.ADOSP1.open;
if dm.ADOSP1.RecordCount > 0 then
begin
CustomerName := dm.ADOSP1.FieldByName('CustomerName').AsString;
end;
except
on e:exception do LogError('Error: '+e.Message);
end;
finally
dm.Free;
end;
So I do open it (or when calling a sp with and update/insert or Delete statement, I use ADOSP1.ExceSql).
What I do not do, is close it, so the error should be Dataset NOT closed rather than Dataset closed. As the procedure exits after, I expect ADOSP1 will be closed without specifically having the code to call adosp1.close;
If could be the properties of the ADOSP1, I need to set differently, but I do not know enough about which or why, so if anybody knows abut these, please feel free to comment.
Regards
Soren
NB! I do still think it is a question of sharing conflicts, like in a non thread safe code.
However, the dataset is not closed at the time of the call. I always use a structure like this:
dm := TApp3TDB.Create(nil);
try
dm.ADOSP1.ProcedureName := 'sp_CustomerGet';
dm.ADOSP1.Parameters.Refresh;
dm.ADOSP1.Parameters.ParamByName('@CustomerNo').value := CustomerNo;
dm.ADOSP1.Prepared := true;
try
dm.ADOSP1.open;
if dm.ADOSP1.RecordCount > 0 then
begin
CustomerName := dm.ADOSP1.FieldByName('CustomerName').AsString;
end;
except
on e:exception do LogError('Error: '+e.Message);
end;
finally
dm.Free;
end;
So I do open it (or when calling a sp with and update/insert or Delete statement, I use ADOSP1.ExceSql).
What I do not do, is close it, so the error should be Dataset NOT closed rather than Dataset closed. As the procedure exits after, I expect ADOSP1 will be closed without specifically having the code to call adosp1.close;
If could be the properties of the ADOSP1, I need to set differently, but I do not know enough about which or why, so if anybody knows abut these, please feel free to comment.
Regards
Soren
NB! I do still think it is a question of sharing conflicts, like in a non thread safe code.

