?
Solved

listbox to sql

Posted on 1997-04-07
1
Medium Priority
?
205 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
[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
1 Comment
 
LVL 2

Accepted Solution

by:
javiertb earned 100 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

762 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