Solved

Delete all records using Query

Posted on 2002-03-31
6
190 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 50 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
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!

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 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