Solved

Parameter query

Posted on 1998-01-07
2
227 Views
Last Modified: 2010-04-04
I have a table with 6 fields and I will like to
link the query parameters from 5 edit controls.  I can do the linking with 1 edit control, but  I need help to extend the linking to five controls.  My source code is like this:

procedure TForm1.Button1Click(Sender: TObject);
var SQL_Pattern, Temp: String;
begin
 if Query1.State <> dsInactive then
 Query1.Close;
 Query1.Clear;
 if Edit1.Text <> '' then begin
 SQL_Pattern := Edit1.Text;
 Temp := 'SELECT * FROM CROP WHERE Protein = ';
 TEmp := Temp + SQL_Pattern;
 Query1.SQL.ADD (Temp);
 Query1.Open;
end;
The other 4 fields are oil, height, yield, and lodging.
I will also appreciate solving the problem in any way that is possible.  Thank you for your help.
0
Comment
Question by:Ogunbo
2 Comments
 
LVL 2

Accepted Solution

by:
mvz121697 earned 70 total points
ID: 1355750
Try something like this:
In this example i assumed that it are all numeric fields,
except the OIL-field (Look at the quotes) :

Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add( 'SELECT * FROM CROP ');
Query1.SQL.Add( 'WHERE Protein = ' + Edit1.Text);
Query1.SQL.Add( ' AND oil = "' + Edit2.Text+'"');
Query1.SQL.Add( ' AND height = ' + Edit3.Text);
Query1.SQL.Add( ' AND yield = ' + Edit4.Text);
Query1.SQL.Add( ' AND lodging = ' + Edit5.Text);
Query1.Open;


0
 

Author Comment

by:Ogunbo
ID: 1355751
Dear  MVZ:
Thank you so much for your help.  You know, this was my first time to post a message and in less than 24 hrs, the question had been answered.  This is great.  Please keep up the good work. I am also thankful to the folks at the experts-exchange site.  May God bless your efforts.

As for the problem, I tried your suggestion for most of the night and it didn't work.  The program compiled successfully, so I knew it must be something small.  This morning, I figured that I needed to put >= or <= in the code.  Otherwise, the values I was using in testing the program did not meet a match, hence the query was returning no records.  However, I have few other questions and I hope you'll find time to answer it.

1.  I have a field called Disease_Resistant and each record will either be yes or no.  I will like to use a check box or a radio button for instance to be used for including crops with yes in their field with the result from the edit boxes.  What syntax do you suggest that I use? Or

2.  If I use a radiobox to hold 2 radio radio buttons, i.e I only want one of the buttons to be operative at a time: with the first button saying : Disease resistant, and the second radiobutton saying: Non resistant.  What will the syntax be like for someone to check on one of the buttons?

Once again thank you very much.  May the Blessings of God be with you and your family.

Sincerely,
  Ogunbo
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 81
Delphi XE10 Round Image 2 154
PHP preg_replace code convert to Delphi 14 66
FMX TEdit KeyUp handler detecting  "enter" key 4 13
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…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 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