Solved

Parameter query

Posted on 1998-01-07
2
230 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
[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 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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