Hello,
I want to create a TAdoStoredProc dynamically, because of multiple threads accessing it.
However, I find that after setting the connection and the procedurename, I still cannot
access the parameters defined in the procedure. Those are only accessible when using
the design-time component. So the question is : Do have to call any special function,
to get this information from the database ( MS SQL Server 2000 ) ?
I'm using Delphi 6 with SP2 installed, here's the relevant source code:
function PrepareProc;
begin
result := TAdoStoredProc.create( nil );
result.connection := MainConnection;
end;
begin
with PrepareProc do
// "working" : with ServerForm.Proc_insertproject do
begin
ProcedureName := 'sp_insertproject';
Parameters.ParamByName('@NAME').Value := NAME; // error : param not found
Parameters.ParamByName('@CATEGORY').Value := CATEGORY;
ExecProc;
Free;
end;
end.
Thanks for your thoughts/input,
Thomas
You have to save the design-time parameters before you make run-time
changes,
something like
var
Params: TParams;
begin
Params := TParams.Create;
try
Params.Assign(ADOStoredProc1);
// do your stuff here...
ADOStoredProc1.Params.Assign(Params);
finally
Params.Free;
end;
end;
"Thomas Lenders" <Thomas....@infas-ttr.de> wrote in message
news:3d4573a6$1_1@dnews...
Thanks, I guess that's a solution.
I just hoped that I could get around having to put about
50 TAdoStoredProc components in my datamodule.
I understood you so as to have the design-time components to store the parameters and then assign these to the dynamic instances when needed. Is that what you meant to say ?
Well, I'll try to find out what exactly is happening in the design-time component, maybe I can just copy the routine to
read to paraminfo from the database somewhere.
Greets,
Thomas
> I understood you so as to have the design-time components to store the
parameters and then assign these to the dynamic instances when needed. Is
that what you meant to say ?
>
Yes.
As soon as you change the SP name, the parameters are reset. That's why you
need to save whatever you had from design time.
--
Jim
Way too late,
I'd still like to point out that the solution to my problem was finding the Parameters.Refresh function. Evidently, the refresh doesn't always happen automatically.
Thanks anyway,
Thomas