Solved

Delete all records using Query

Posted on 2002-03-31
6
184 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
Technology Partners: 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

Independent Software Vendors: 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

756 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