Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Parametrizing SQL commands.

Posted on 2000-04-04
10
Medium Priority
?
156 Views
Last Modified: 2010-04-04
I use a TQuery component for SQL commands. I execute a SQL
command using, for exemple, the sequence:
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add ('select * from file where Code>= 20');
      Query1.Open;
I want to use Query1.Params property to parametrize the value "20".
How to do that? I need un example.
0
Comment
Question by:val84
[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
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 1

Expert Comment

by:bakry99
ID: 2686411
Hi ,,
  You Can do The
      Query1.Close;
      Query1.SQL.Clear;
      Query1.SQL.Add ('select * from file where Code>= '+ Edit1.Text);
      Query1.Open;
0
 
LVL 1

Expert Comment

by:bakry99
ID: 2686427
or
st:=   inputBox('','Inout Code You want to search for','');
Query1.SQL.Add ('select * from file where Code>= '+ st);


  Bakry
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2686443
What kind of database did you want to use, is it desktop or Client/Server?

Motaz
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:aubs
ID: 2686499
Hi Val84,

Something like this perhaps...

Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add ('select * from file where Code>= :Code');
Query1.ParamByName('Code').AsInteger:= 20;
Query1.Open;

Regards
Aubs

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2686524
too late, aubs wins :-))
0
 

Expert Comment

by:Volk
ID: 2686703
You'll still have to add the parameter though, don't forget to specify a type for the parameter (Integer in your case) when using the Object Inspector. From you code:

Query1.Params.CreateParam (ftInteger, 'Code', ptInput);

You only have to create it once.

Good luck,

JAAP
0
 

Expert Comment

by:Volk
ID: 2686706
Volk changed the proposed answer to a comment
0
 

Author Comment

by:val84
ID: 2686765
Really Aubs won. I tested it and it's OK.
Thanks all of you. Alex.
0
 
LVL 2

Accepted Solution

by:
aubs earned 400 total points
ID: 2686996
Query1.Close;
                      Query1.SQL.Clear;
                      Query1.SQL.Add ('select * from file where Code>= :Code');
                      Query1.ParamByName('Code').AsInteger:= 20;
                      Query1.Open;
0
 

Author Comment

by:val84
ID: 2688771
I am late with the acceptance because I had problems with the Net.
Thanks a lot. Alex.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

705 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