Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delete all records using Query

Posted on 2002-03-31
6
Medium Priority
?
209 Views
Last Modified: 2011-09-20
i have my database name DataEntries.DB
with fields 1:KeyCode (Autoincremental)
            2:BatchNo (STring)
            3:Descripton

My question is how can i delete all records
having a BatchNo = '044' using the Tquery component?

here is some example of my code, it returns
"invalid token"

Procedure DeleteAll(thetablename:twwtable;thedatasource:Twwdatasource;fieldname,deletestring:string);
begin

fmastermodule.query1.Active:=false;

fmastermodule.query1.SQL.Text:= 'delete '+thetablename.TableName+' where '+fieldname+' = '''+deletestring+'''';

fmastermodule.query1.ExecSQL;


**Can anybody give me some GOOD CODE for this?
0
Comment
Question by:girlswants_me
[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
  • 2
  • 2
6 Comments
 

Author Comment

by:girlswants_me
ID: 6909632
HELP ME PLEASE
0
 
LVL 6

Expert Comment

by:kotan
ID: 6909646
The delete syntax should be

delete from ...
0
 
LVL 6

Accepted Solution

by:
DrDelphi earned 200 total points
ID: 6909650
seems to me that your SQL statement is missing the word "from"..

Example:

var table:string;
begin
  table:='Clients';
Query1.Sql.add('delete  from '+Table+' where  LAST_Name= ''Jones''');
  Query1.execsql;
end;





Good luck!!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:girlswants_me
ID: 6909707
Thank you so much
0
 
LVL 6

Expert Comment

by:kotan
ID: 6909717
Did you see my comment? I gave the answer first.
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6910296
Kotan,
  I cannot tell you how many times I have had the same thing happen to me. I'll reply only to have someone else collect the points. In my defense however, I have to say that girlswants_me's question DID specifiy that he/she was looking for a code example, which I supplied and you didn't. Granted, I understood what you meant, but strictly speaking it did not answer the question posed.


Good luck!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

715 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