if FileExists(BKFileName) then if MessageBox(Handle, Pchar('Îļþ£º' + BKFileName + 'ÒѾ­´æÔÚ£¬ÊÇ·ñ¸²¸Ç£¿'), 'ϵͳÌáʾ', MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> IDYES then Exit; BackUp.SQL.Clear; BackUp.SQL.Add('Backup Database TaxiCarMIS to Disk=''' + BKFileName + ''' With Init'); try SpeedButton2.Enabled := False; SpeedButton5.Enabled := False; Label1.Font.Color := clRed; Label1.Caption := 'Êý¾Ý¿â±¸·ÝÖУ¬ÇëÉÔºî...'; Self.Refresh; Application.ProcessMessages; BackUp.ExecSQL; SpeedButton2.Enabled := True; SpeedButton5.Enabled := True; Label1.Font.Color := clBlue; Label1.Caption := '±¸·ÝÊý¾Ý¿â...'; MessageBox(Handle, Pchar('ÒѾ­³É¹¦±¸·ÝÊý¾Ý¿âµ½£º' + BKFileName), 'ϵͳÌáʾ', MB_OK or MB_ICONINFORMATION); except on E: Exception do begin SpeedButton2.Enabled := True; SpeedButton5.Enabled := True; Label1.Font.Color := clBlue; Label1.Caption := '±¸·ÝÊý¾Ý¿â...'; MessageBox(Handle, Pchar('±¸·ÝÊý¾Ý¿âûÓгɹ¦£¬Çë¼ì²é£¡' + #13 + '³ö´íÐÅÏ¢£º' + E.Message), 'ϵͳÌáʾ', MB_OK or MB_ICONERROR); end; end;
这么多转义符。看来是从网页上down的:) 搜一下以前的帖子吧,例子多的够你从现在一直看到建军节!
Access 复制粘贴就可以了 SQl: with query do begin close; Sql.clear; sql.add('BACKUP DATABASE 数据库 TO DISK = c:\aaa') try execsql; except showmessage('cuo wu'); end; end; SQl.add('RESTORE 数据库 FROM c:\aaa WITH NORECOVERY')
if MessageBox(Handle, Pchar('Îļþ£º' + BKFileName + 'ÒѾ­´æÔÚ£¬ÊÇ·ñ¸²¸Ç£¿'), 'ϵͳÌáʾ', MB_YESNO or MB_ICONWARNING or MB_DEFBUTTON2) <> IDYES then Exit;
BackUp.SQL.Clear;
BackUp.SQL.Add('Backup Database TaxiCarMIS to Disk=''' + BKFileName + ''' With Init');
try
SpeedButton2.Enabled := False;
SpeedButton5.Enabled := False;
Label1.Font.Color := clRed;
Label1.Caption := 'Êý¾Ý¿â±¸·ÝÖУ¬ÇëÉÔºî...';
Self.Refresh;
Application.ProcessMessages;
BackUp.ExecSQL;
SpeedButton2.Enabled := True;
SpeedButton5.Enabled := True;
Label1.Font.Color := clBlue;
Label1.Caption := '±¸·ÝÊý¾Ý¿â...';
MessageBox(Handle, Pchar('ÒѾ­³É¹¦±¸·ÝÊý¾Ý¿âµ½£º' + BKFileName), 'ϵͳÌáʾ', MB_OK or MB_ICONINFORMATION);
except on E: Exception do
begin
SpeedButton2.Enabled := True;
SpeedButton5.Enabled := True;
Label1.Font.Color := clBlue;
Label1.Caption := '±¸·ÝÊý¾Ý¿â...';
MessageBox(Handle, Pchar('±¸·ÝÊý¾Ý¿âûÓгɹ¦£¬Çë¼ì²é£¡' + #13 + '³ö´íÐÅÏ¢£º' + E.Message), 'ϵͳÌáʾ', MB_OK or MB_ICONERROR);
end;
end;
搜一下以前的帖子吧,例子多的够你从现在一直看到建军节!
SQl:
with query do
begin
close;
Sql.clear;
sql.add('BACKUP DATABASE 数据库 TO DISK = c:\aaa')
try
execsql;
except
showmessage('cuo wu');
end;
end;
SQl.add('RESTORE 数据库 FROM c:\aaa WITH NORECOVERY')