恢复数据库:因为你正在打开的数据库所以先关闭(我用的是ADO你改以下就可以了)
DM.CLE_Connect.Connected := False;
MySQL := 'ALTER DATABASE DB_CLE SET OFFLINE WITH ROLLBACK IMMEDIATE'; //关闭数据库
with ADOQueryRestor do
begin
Close;
SQL.Clear;
SQL.Text := MySQL;
try
ExecSQL;
except
end;
end;
RestorStr := 'RESTORE DATABASE DB_CLE FROM DISK = ''' + Trim(e_lj.Text) + ''' WITH REPLACE';
with ADOQueryRestor do
begin
Close;
SQL.Clear;
SQL.Text := RestorStr;
try
ExecSQL;
Application.MessageBox('恢复数据库成功!','提示!',mb_ok+mb_iconinformation);
except
Application.MessageBox('恢复数据库出错!','错误!',mb_ok+mb_iconError);
end;
end;
MySQL := 'ALTER DATABASE DB_CLE SET ONLINE WITH ROLLBACK IMMEDIATE';
with ADOQueryRestor do
begin
Close;
SQL.Clear;
SQL.Text := MySQL;
try
ExecSQL;
except