adocommand1.ConnectionString:=ConnectionString; With AdoCommand1 Do Begin filename:=OpenDialog1.FileName; CommandText:='use Master'; Execute; CommandText:='Alter Database aa Set Offline with Rollback immediate'; Execute; sql:='ReStore DataBase aa From Disk='''+filename+''' with replace'; CommandText:=sql; Execute ; commandText:='alter database aa set online with rollback immediate'; Execute; End; 其中aa 为数据库名
backup database tour to disk='d:\back1.bak'
RESTORE DATABASE tour from disk='d:\back1.bak'注tour是数据库名。
With AdoCommand1 Do
Begin
filename:=OpenDialog1.FileName;
CommandText:='use Master';
Execute;
CommandText:='Alter Database aa Set Offline with Rollback immediate';
Execute;
sql:='ReStore DataBase aa From Disk='''+filename+''' with replace';
CommandText:=sql;
Execute ;
commandText:='alter database aa set online with rollback immediate';
Execute;
End;
其中aa 为数据库名