Stored procedure parameters with TADODataset or TADOCOmmand



I have a stored procedure which looks something like:

create procedure get_anid @in_col1 char(16), @Out_anid int OUTPUT as

declare @wk_anid integer

set @wk_anid = ( select max(id) from table where col1 = @in_col1 );
set @Out_anid = @wk_anid


How do I use TADODataSet to call this and have the number returned at
runtime. I'm stuck on how to set up the parameters. The code I have got so
far is:

with TADOdataset.Create(Application) do try
ParamCheck := False;
Connection := AxGlob.ADO.Connection;

CommandType := cmdStoredProc;
CommandText := 'get_anid';

param := parameters.AddParameter;
with param do begin
Name := '@in_col1';
DataType := ftString;
Direction := pdInput;
Value := axtQS('col1text');
end;

param := parameters.AddParameter;
with param do begin
Name := '@out_anid';
DataType := ftInteger;
Direction := pdOutput;
end;

try
Open();
except
; // do nothing
end;

pID := parameters.ParamByName('@out_anid').Value;
result := (pID >= 0);

finally
free;
end;

Thanks for your help,

Mike


.



Relevant Pages

  • Re: Accessing Stored Procedure from IIS
    ... Make sure the stored procedure has SET NOCOUNT ON at the beginning. ... > execution falls right through without adding the customer or incrementing ... > adovbs.inc is linked and the "conditional code" I refer to swaps the ... > adocmd.parameters.append param ...
    (microsoft.public.inetserver.asp.general)
  • Re: Accessing Stored Procedure from IIS
    ... Make sure the stored procedure has SET NOCOUNT ON at the beginning. ... > execution falls right through without adding the customer or incrementing ... > adovbs.inc is linked and the "conditional code" I refer to swaps the ... > adocmd.parameters.append param ...
    (microsoft.public.sqlserver.programming)
  • Re: Parameter.Add() problem
    ... Cor's previous post tells you how to add a parameter to you command ... In your particular case you can't use the param to the ... how do I use this parameter within a stored procedure? ... > within the SPROC. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Parameter.Add() problem
    ... > Hey Timothy, ... > Cor's previous post tells you how to add a parameter to you command ... In your particular case you can't use the param to the ... how do I use this parameter within a stored procedure? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: stored proc RETURN_VALUE.... there it is, I want to use it !!!
    ... sorry Ron... ... get the stored procedure to run like every other stored procedure that I've ... > Then you can read the value of @total after closing the query. ... > 2 Set up your input param values. ...
    (borland.public.delphi.database.ado)