Mega Code Archive

 
Categories / Delphi / ADO Database
 

Empty a database, leaving just its structure

Title: Empty a database, leaving just its structure Question: Empty a database, leaving just its structure Answer: Sometimes it's interesting empty a database, leaving just its structure. Here you have an example of this: NOTE: This example do not work in edit mode... just in runtime because the table must be open in excusive mode. procedure TForm1.Button2Click(Sender: TObject); begin {Opens the table in exclusive mode} Try With Table1 Do Begin Active:=False; Exclusive:=True; Active:=True; try EmptyTable; except ShowMessage('Cannot empty database'); end; End Except ShowMessage('cannot open table in exclusive mode'); End end;