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?
 
XANConnect With a Mentor Commented:
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
 
rwilson032697Commented:
Listening
0
 
yk030299Commented:
listen
0
 
Mr_PeerapolCommented:
Listening as well
0
 
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
All Courses

From novice to tech pro — start learning today.