//备份
procedure TSFBH.BitBtn4Click(Sender: TObject);
var
FilePath: String;
i: integer;
str,s: String;
begin
if edit1.Text<>'' then
try
for i:=0 to combobox2.Items.Count-1 do
begin
BackFileName:=Trim(combobox2.Items[i]); //取得备份文件名
//取得地址框中的地址
if RightStr(Edit1.text,1)='\' then
FilePath:=Edit1.Text
else
FilePath:=Edit1.Text+'\';
FilePath:=FilePath+BackFileName;
screen.Cursor:=crSqlWait;
// BackupBase(FilePath); //调用备份过程备份文件
screen.Cursor:=crSqlWait;
str:='Backup Database '+Trim(Combobox2.Items[i])+' to Disk='''+FilePath+''' ';
with adoQuery1 do
begin
close;
Sql.Text:=str;
ExecSQL;
end;
end;
screen.Cursor:=crDefault;
MessageBox(handle,'备份成功!','信息',MB_Iconinformation+mb_Ok);
except
MessageBox(handle,'备份失败!','提示',MB_IconWarning+mb_Ok);
screen.Cursor:=crDefault;
Exit;
end;
end;
//还原
procedure TSFBH.BitBtn5Click(Sender: TObject);
begin
adoquery2.Close;
try
with adoquery2 do
begin
close;
sql.Clear;
sql.add('restore database mdf from disk=''F:\SFBH\text''');
execsql;
end;
showmessage('还原成功');
except
on e:exception do
showmessage('还原失败');
end;
end;
end.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以上是数据库 备份与还原, 备份后生成 SQL中数据库名为 text 文件
还原时就会出错!!!
哪为高手帮我解决一下~~~~~~~~~~~~~~~