各位兄弟请帮看一下在我备份数据库时老是出现错误代码如下:procedure TForm1.Button2Click(Sender: TObject);
begin
with Query1 do
begin
Close;
SQL.Clear;
SQL.Add('backup database ghome TO disk "c:\yu\home.bak"');
ExecSQL;
end;
end;
begin
with Query1 do
begin
Close;
SQL.Clear;
SQL.Add('backup database ghome TO disk "c:\yu\home.bak"');
ExecSQL;
end;
end;
var
filename:string;
begin
statusbar1.SimpleText :='正在备份中.....';
Filename:='pubs' + formatDatetime('yyyy-mm-dd',now);
adoconnection1.Close ;
begin
try
adocommand1.CommandText :='use master';
adocommand1.Execute ;
adocommand1.CommandText :='execute sp_helpdevice';
adocommand1.Execute ;
adocommand1.CommandText :='backup database pubs to disk='''+'f:\'+filename+''' with init';
adocommand1.Execute ;
adocommand1.CommandText :='use pubs';
adocommand1.Execute ;
// application.MessageBox(pchar('backup database ok'+filenamegsysname,mb_ok+mb_iconinfomation);
application.MessageBox('数据库已经成功备份到','系统对话框',mb_ok);
try
ADOConnection1.Connected :=true;
except
begin
statusbar1.SimpleText :='';
Application.MessageBox('连接数据库错误','asd',MB_OK+mb_iconerror);
abort;
end;
end;
except
on Exception do
if adoconnection1.InTransaction then
adoconnection1.RollbackTrans ;
end;
end;
end;我用这个备份,你试一下吧
'backup database ghome TO disk ''c:\yu\home.bak''')
QuotedStr(BackupFileName) + ' WITH INIT';
SQL.Add(l_SQL);