Solved

listbox to sql

Posted on 1997-04-07
1
193 Views
Last Modified: 2010-04-06
I have a listbox that may contain the name of Cities that I want later to construct a sql statement that will locate these cities within a table. What is the right statement to build the string that would be used in the sql statement
0
Comment
Question by:azal
1 Comment
 
LVL 2

Accepted Solution

by:
javiertb earned 50 total points
ID: 1335238
Query1.Close;
Query1.SQL.Add('Select * from Table');

iSelected:=listBox.SelCount;

if (iSelected>0) then
   Query1.SQL.Add(' where ');

icount:=0;

while (iSelected>0) do
begin
   if (listBox.Selected[icount]) then
   begin
      Query1.SQL.Add(' city= '+ listBox.Items[icount]);
     
      iSelected:=iSelected-1;
     
      if (iSelected>0) then
         Query1.SQL.Add(' and ');      
   end

   icount:=icount+1;
end;

Query1.ExecSQL;


If you've got any problem, let me know.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 91
how to send memory stream from ics Client To ics server ? 11 175
Delphi: sending SMS on android platform 1 63
MS Access from Delphi 31 78
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 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