Q:

Executing a stored procedure twice using TAdoStoredProc in Delphi

I'm using Delphi 10.1 Berlin and I needed to use TAdoStoredProc in my project. I don't use any non-visual component in my forms or data modules. All my connection and db components are creating at run-time.
My Question: When I'm trying to execute TAdoStoredProc, it executes twice and my insert, update processes have worked twice. 
var
  mSp: TADOStoredProc;
  i: Integer;
begin
  mSp := TADOStoredProc.Create(nil);
  mSp.Connection := conn;
  mSp.ProcedureName := spname;
  mSp.CommandTimeout := 600;
  mSp.parameters.Refresh;
  for i := 0 to parameters.Count - 1 do
  begin
    mSp.parameters.ParamByName(parameters[i].Name).Value := parameters[i].Value;
  end;
  mSp.ExecProc;
  mSp.Open;
  Result := mSp;

What should I do or change? Thanks.

A:

As I see that your code required some return values. So you should use TAdoStoredProc like TAdoQuery. You don't need to use ExecProc function for execute, try to use only Open function.
You can just check out TADOStoredProc.ExecProc Method documentation from here.

If an application is only interested in the result set returned by a stored procedure, call Open method for the TADOStoredProc component or set its Active property to true. 

