Search code examples
delphidelphi-7

Delphi - Clear Param Data for TADOStoredProc


for BDE, we can clear the param data like below.

 with tstoredproc do
    begin
    .
    .
      for i := 0 to ParamCount - 1 do Params[i].Clear;
    .
    .

    end

how to do the same for ADO Dataset's? I do not want to create params. i am using TADOStoredProc component and it is having all the params. i Just need to clear data and assign new data.

with TADoStoredProc do
begin
.
.
 for i := 0 to ParamCount - 1 do Parameters[i].Value := null; -- is this right? or can i use below line of code
 Parameters.Refresh
.
.
end;

Solution

  • BDE TParam.Clear sets Unassigned for the data member of the parameter.

    i Just need to clear data and assign new data

    Why do you need to clear the data/value in the first place? simply assign the new values.

    If you need to explicitly pass null to the stored procedure parameter you can use e.g.

    Parameters[i].Value := Unassigned