Solved

listbox to sql

Posted on 1997-04-07
1
186 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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