Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi ADO Access

Status
Not open for further replies.

Blackadder6

Programmer
Apr 16, 2005
1
AU
I want delete all the records in an Access table.
The code below does not work.

procedure TForm1.Emptytable2Click(Sender: TObject);
begin
AdoQuery1.SQL.Add('DELETE from dupmaster');
AdoQuery1.ExecSQL;
end;

If I use 'DELETE * from dupmaster

I still get the same error message which is "exception class EOleException with message Syntax error in FROM clause.

Can anyone hlp me. I wonder if I need to close the database or something like that.

Terry
 
Hi,

Below is a variation of some code I'm using which works -

with AdoQuery1 do begin
Active:= False;
SQL.Clear;
SQL.Add('DELETE * from dupmaster');
Prepared:= True;
ExecSQL;
end;

Regards
 
Is your database using replication? If not, you could also use TRUNCATE <tablename>. This is extremely fast but dirty because it doesn't write anything to the transaction log so you can not roll back if something goes wrong. If rolling back is not important and it's not replicated I'd be tempted to use this (assuming you have privileges as well [smile2]).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top