unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, DB, DBTables;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Label1: TLabel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Query1: TQuery;
    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('exec sp_detach_db "DB2010","true"');
      ExecSQL;
    end;
      Application.MessageBox('数据库分离成功!','提示',64);
  Except
      Application.MessageBox('数据库分离失败!','提示',64);
  end;
end;

end.
posted on 2011-04-11 22:10  巅枫  阅读(464)  评论(0编辑  收藏  举报