?
Solved

SQL-statement..

Posted on 2000-03-10
6
Medium Priority
?
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Accepted Solution

by:
guntherds earned 400 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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