Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using TAdoStoredProc dynamically / missing parameters

888 views
Skip to first unread message

Thomas Lenders

unread,
Jul 29, 2002, 12:56:06 PM7/29/02
to

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

Jim Elden

unread,
Jul 29, 2002, 1:26:28 PM7/29/02
to
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...

Thomas Lenders

unread,
Jul 30, 2002, 5:12:39 AM7/30/02
to

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

Jim Elden

unread,
Jul 30, 2002, 7:26:00 AM7/30/02
to
Hi 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


Thomas Lenders

unread,
Aug 15, 2002, 11:16:45 AM8/15/02
to

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

0 new messages