try
with SQL do begin
Add('SELECT ... ');
Add('FROM .....');
Add('WHERE .....);
Add('AND CUSTOMER_ID = :CustId');
end;
ParamByName('CustId').AsString := '1';
you were trying to add a parameter that had already been created (by using
:CustId in the SQL statement you had already created a parameter called
CustId)
Regards
Sammy !!
----- Original Message -----
From: "Sergei Stenkov" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Thursday, June 21, 2001 5:18 PM
Subject: [DUG]: Run time TQuery problem
> Hello,
>
> I have a problem with running a query created at run time. (use D5 on 2K
and
> Oracle 8.17)
> Both TDatabase and TQuery comps are created and set at run time and when I
> try execute the query, I get a EDBEngineError saying "Could not find
> object".
> Executing the same query with comps created at design time has no problem
> what so ever. The run time creation is shown in the following piece of
code.
>
> The question is - Am I missing out something or doing something wrong? Or,
> what could be wrong here?
>
> Thank you for any suggestions.
>
> Best regards,
> Sergei
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> procedure TForm1.Button1Click(Sender: TObject);
> var
> sqlTrans : TQuery;
> dbTrans : TDatabase;
> begin
> dbTrans := TDatabase.Create(nil);
> sqlTrans := TQuery.Create(nil);
> try
> with dbTrans do begin
> DatabaseName := 'Blah';
> AliasName := 'BlahAlias';
> Params.Add('USER NAME=USERNAME');
> Params.Add('PASSWORD=USERPASSWORD');
> LoginPrompt := False;
> Connected := True;
> end;
>
> with sqlTrans do begin
> DatabaseName := 'Blah';
>
> with SQL do begin
> Add('SELECT ...');
> Add('FROM ...');
> Add('WHERE ...');
> Add('AND CUSTOMER_ID = :CustId');
> end;
>
> with Params do begin
> CreateParam(ftString, 'CustId', ptInput);
> ParamByName('CustId').AsString := '1';
> end;
>
> Open; // Fails here
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> First;
> ...............
> Close;
> end;
> finally
> if sqlTrans.Active then sqlTrans.Close;
> sqlTrans.Free;
> if dbTrans.Connected then dbTrans.Connected := False;
> dbTrans.Free;
> end;
> end;
>
> --------------------------------------------------------------------------
-
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"