Solved

Delete all records using Query

Posted on 2002-03-31
6
164 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

20 Experts available now in Live!

Get 1:1 Help Now