procedure TForm1.Button2Click(Sender: TObject); begin ADOQuery1.Close; ADOQuery1.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master'; try with ADOQuery1 do begin Close; SQL.Clear; SQL.Add('restore database PeoMan from disk = ''c:\back1.bak'''); ExecSQL; end; ShowMessage('还原成功。'); except On e: exception do ShowMessage('还原失败。'); end; end;procedure TForm1.Button3Click(Sender: TObject); begin ADOQuery1.Close; ADOQuery1.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=PeoMan'; try with ADOQuery1 do begin Close; SQL.Clear; SQL.Add('backup database PeoMan to disk = ''c:\back1.bak'''); ExecSQL; end; ShowMessage('备份成功。'); except On e: exception do ShowMessage('备份失败。'); end; end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ADOQuery1.Close;
ADOQuery1.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master';
try
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('restore database PeoMan from disk = ''c:\back1.bak''');
ExecSQL;
end;
ShowMessage('还原成功。');
except
On e: exception do
ShowMessage('还原失败。');
end;
end;procedure TForm1.Button3Click(Sender: TObject);
begin
ADOQuery1.Close;
ADOQuery1.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=PeoMan';
try
with ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('backup database PeoMan to disk = ''c:\back1.bak''');
ExecSQL;
end;
ShowMessage('备份成功。');
except
On e: exception do
ShowMessage('备份失败。');
end;
end;