Solved

SQL-statement..

Posted on 2000-03-10
6
210 Views
Last Modified: 2010-04-04
What is wrong with the following:

  Query1.SQL.Add('SELECT * FROM DETAIL WHERE ID = :PARAM');
  Query1.ParamByName('PARAM').AsInteger:=Table1.FieldByName('ID').AsInteger;
  Query1.Open;



I get "Cannot find Parameter: Param"

Why ?

I haven't touched the properties, except for Datasource and DataBasename..
I also tried Query1.ExecSQL, but no difference..

/Thanx !
0
Comment
Question by:Erik N
6 Comments
 

Accepted Solution

by:
guntherds earned 100 total points
ID: 2605165
You must also add the PARAM-parameter to the Params-list of the query at run-time, then it will work

Gunther
0
 

Expert Comment

by:andybun
ID: 2605251
Query1.SQL.Clear;
Query1.SQL.Add('SELECT * FROM DETAIL WHERE ID = :PARAM');
  Query1.ParamByName('PARAM').AsInteger:=Table1.FieldByName('ID').AsInteger;
  Query1.Open;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2607492
hmm,

seems to be ok,
maybe you should give the param another name or
do a query.prepare before assigning the param like

Query1.SQL.Add('SELECT * FROM DETAIL WHERE ID = :PARAM');
Query1.Prepare;
Query1.ParamByName('PARAM').AsInteger:=Table1.FieldByName('ID').AsInteger;
Query1.Open;

meikl
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:sunsetyang
ID: 2607612
Perhaps the type of ID is smallint,so you should write it as Query1.ParamByName('Param').AsSmallint:=....If it doesn't work either,You can write the statement as below:
 Query1.Params[0].AsInteger(Smallint):=...
 This will work absolutely!:-)
 
0
 

Expert Comment

by:evdzwan
ID: 2608396
Just another option is not to use a parameter at all. If you already know which id you need, just used it in the query it self. It is faster.

Try :

Query1.sql.add('select * from Detail where id = ' + strToInt(Table1.FieldByName('id').asInteger))
Query1.open;

ok?
0
 

Author Comment

by:Erik N
ID: 2609256
The error was in the syntax:
SELECT * FROM DETAIL WHERE ID = : PARAM
was replaced by:
SELECT * FROM DETAIL WHERE ID = :PARAM

This seems to be a little sensitive..

Thanx, all of you !

/Erik N
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now