unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, StdCtrls, Buttons, Grids, DBGrids;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Query1: TQuery;
DataSource1: TDataSource;
Label1: TLabel;
Table1: TTable;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
try
with Query1 do
begin
close;
SQL.clear;
SQL.Add('dbcc shrinkdatabase(DB2010)');
ExecSQL;
end;
Application.MessageBox('数据库压缩成功!','提示',64);
Except
Application.MessageBox('数据库压缩失败!','提示',64);
end;
end;
end.
转载于:https://www.cnblogs.com/keyvip/archive/2011/04/11/2012974.html