L
liubin44966
Unregistered / Unconfirmed
GUEST, unregistred user!
dm.ADOConnection1//业务数据库连接
ADOConnection2//连接master 数据库
dm.ADOConnection1.Connected:=false;
ADOConnection2.Connected:=false;
ADOConnection2.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master; Data Source=aa';
ADOConnection2.Connected:=true;
adoquery1.connection:=ADOConnection2;
with adoquery1 do
begin
close;
sql.clear;
sql.add('USE master restore filelistonly from disk =''D:/tzsbgl(sql)/备份/特种设备数据 (2005-12-13).JA'' ')
sql.add('restore database tzsb' );
sql.add(' from disk =''D:/tzsbgl(sql)/备份/特种设备数据 (2005-12-13).JA'' ');
sql.add(' WITH move 'tzsb_Data' to ''D:/tzsbgl(sql)/tzsb_Data.MDF'' ');
sql.add(' , move 'tzsb_Log' to ''D:/tzsbgl(sql)/tzsb_Log.LDF'' ,replace');
try
ExecSQL;
Application.MessageBox('恭喜您恢复数据库成功!','提示',MB_OK+MB_ICONEXCLAMATION);
except
on E:Exception do
begin
Application.MessageBox(pchar(e.Message),'提示',MB_OK+MB_ICONEXCLAMATION);
exit;
end;
end;
end;
ADOConnection2//连接master 数据库
dm.ADOConnection1.Connected:=false;
ADOConnection2.Connected:=false;
ADOConnection2.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master; Data Source=aa';
ADOConnection2.Connected:=true;
adoquery1.connection:=ADOConnection2;
with adoquery1 do
begin
close;
sql.clear;
sql.add('USE master restore filelistonly from disk =''D:/tzsbgl(sql)/备份/特种设备数据 (2005-12-13).JA'' ')
sql.add('restore database tzsb' );
sql.add(' from disk =''D:/tzsbgl(sql)/备份/特种设备数据 (2005-12-13).JA'' ');
sql.add(' WITH move 'tzsb_Data' to ''D:/tzsbgl(sql)/tzsb_Data.MDF'' ');
sql.add(' , move 'tzsb_Log' to ''D:/tzsbgl(sql)/tzsb_Log.LDF'' ,replace');
try
ExecSQL;
Application.MessageBox('恭喜您恢复数据库成功!','提示',MB_OK+MB_ICONEXCLAMATION);
except
on E:Exception do
begin
Application.MessageBox(pchar(e.Message),'提示',MB_OK+MB_ICONEXCLAMATION);
exit;
end;
end;
end;