F
fuxin198311
Unregistered / Unconfirmed
GUEST, unregistred user!
本人在做数据库的备份与恢复 用的是SQL2000 备份现在没有问题 可是当我恢复数据时
提示:因为数据库正在使用,所以未能获得对数据库的排它访问权
代码是这样的:
procedure TForm1.Button2Click(Sender: TObject);//数据恢复
begin
opendialog1.InitialDir:=extractfilepath(application.ExeName)+'backup' ;
if opendialog1.Execute then
begin
adoconnection1.Connected:=false;
with adoquery1 do
begin
close;
sql.Clear ;
sql.Text:='restore DATABASE fuxin from DISK='''+opendialog1.FileName+'''';
showmessage(sql.Text);
ExecSQL ;
end;
adoconnection1.Connected:=true;
end;
end;
提示:因为数据库正在使用,所以未能获得对数据库的排它访问权
代码是这样的:
procedure TForm1.Button2Click(Sender: TObject);//数据恢复
begin
opendialog1.InitialDir:=extractfilepath(application.ExeName)+'backup' ;
if opendialog1.Execute then
begin
adoconnection1.Connected:=false;
with adoquery1 do
begin
close;
sql.Clear ;
sql.Text:='restore DATABASE fuxin from DISK='''+opendialog1.FileName+'''';
showmessage(sql.Text);
ExecSQL ;
end;
adoconnection1.Connected:=true;
end;
end;