return parameters in stored procedure


Hi,
   I am trying to get a return value for a stored procedure.I've
declared an output parameter in the stored procedure.Now I try to
retrieve the output value.It goes like this
Comm : _Command;
ParamArray : olevariant
Re : integer;

     Comm._Set_ActiveConnection(Conn);
     Comm.Set_CommandText('Inserttopic');
     Comm.Set_CommandType(adCmdStoredProc);
     ParamArray := VarArrayOf([TopicName,CommunityID,Re]);
     Comm.Execute(a,ParamArray,0);
     a1 := Comm.Parameters[2].Get_Value;

All I get is what I pass in Re.Which is the output parameter, though I
am setting it in the stored procedure
How do I get it.
                                  Thank u
                                   Manju.
manjushanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rwilson032697Commented:
Listening
0
yk030299Commented:
listen
0
Mr_PeerapolCommented:
Listening as well
0
XANCommented:
var
Cmd: Command;

begin
  Cmd := CoCommand.Create;
  Cmd.Set_ActiveConnection(Conn);
  Cmd.Set_CommandText('Inserttopic');
  Cmd.Set_CommandType(adCmdStoredProc);
----
  cmd.Parameters.Refresh; { It's not very well idea to make refresh - slowly and many work for DB server}
  cmd.Parameters[1].Set_Value(...);
  ...
  cmd.Execute(...);
  Result := cmd.Parameters[2].Get_Value;
----
  {more fast in work the next way - this is part of my code}

  {This is parameter [0] for Return Code of stored proc}
  cmd.Parameters.Append(cmd.CreateParameter('Return', adInteger, adParamReturnValue, 4, -1));
  cmd.Parameters.Append(cmd.CreateParameter('@Name', adVarChar, adParamInput, 100, ProfileName));
    cmd.Parameters.Append(cmd.CreateParameter('@Hidden', adBoolean, adParamInput, 1, 0));
    cmd.Parameters.Append(cmd.CreateParameter('@ID', adInteger, adParamOutput, 4, -1));
    cmd.Execute(EmptyParam, EmptyParam, adCmdStoredProc);
    Result := cmd.Parameters.Item['@ID'].Value;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
manjushanAuthor Commented:
Thanks XAN,
          I have already tried the method u have posted. I wanted a way using only a ParamArray and get the output value. Finaly I discovered that all I have to add in my code is

       Command.Parameter.Refresh.

Thanks anyway. U got the points.
                            Manju
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.