Solved

Delete all records using Query

Posted on 2002-03-31
6
172 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
  • 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now