我作了一个与数据库相关的小软件,备份没问题,就是恢复时说正在使用,一般来说数据备份和恢复不是备份和恢复整个数据库吗?
我的代码:就是没有进度的,我也没知道怎么加进去,谁帮下,谢谢
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm)
Button1: TButton;
dlgOpen1: TOpenDialog;
con1: TADOConnection;
qry1: TADOQuery;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
if dlgOpen1.Execute then
begin
try
con1.Connected:=False;
con1.Connected:=True;
with qry1 do
begin
Close;
SQL.Clear;
SQL.Add('Backup DataBase test to disk = '''+dlgopen1.FileName+ '''');
ExecSQL;
end;
except
ShowMessage( '备份失败 ');
Exit;
end;
end;
Application.MessageBox( '备份成功 ', '备份信息 ',MB_OK + MB_ICONINFORMATION);
end;procedure TForm1.Button2Click(Sender: TObject);
begin if dlgOpen1.Execute then
begin
try
con1.Connected:=false;
con1.Connected:=true;
with qry1 do
begin
Close;
SQL.Clear;
SQL.Add( 'Restore DataBase test from disk = '''+dlgopen1.FileName+ '''');
ExecSQL;
end;
except
ShowMessage( '恢复数据失败 ');
Exit;
end;
end;
Application.MessageBox( '恢复数据成功 ', '恢复信息 ',MB_OK + MB_ICONINFORMATION);
end;end.
我的代码:就是没有进度的,我也没知道怎么加进去,谁帮下,谢谢
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm)
Button1: TButton;
dlgOpen1: TOpenDialog;
con1: TADOConnection;
qry1: TADOQuery;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
if dlgOpen1.Execute then
begin
try
con1.Connected:=False;
con1.Connected:=True;
with qry1 do
begin
Close;
SQL.Clear;
SQL.Add('Backup DataBase test to disk = '''+dlgopen1.FileName+ '''');
ExecSQL;
end;
except
ShowMessage( '备份失败 ');
Exit;
end;
end;
Application.MessageBox( '备份成功 ', '备份信息 ',MB_OK + MB_ICONINFORMATION);
end;procedure TForm1.Button2Click(Sender: TObject);
begin if dlgOpen1.Execute then
begin
try
con1.Connected:=false;
con1.Connected:=true;
with qry1 do
begin
Close;
SQL.Clear;
SQL.Add( 'Restore DataBase test from disk = '''+dlgopen1.FileName+ '''');
ExecSQL;
end;
except
ShowMessage( '恢复数据失败 ');
Exit;
end;
end;
Application.MessageBox( '恢复数据成功 ', '恢复信息 ',MB_OK + MB_ICONINFORMATION);
end;end.
解决方案 »
- 关于显示属性的大小字体在程序中影响的问题???????????????????????????
- 很难的GBgrid隐藏列问题(解决者可另开高分)
- Query1 : Parameter 'a' not found
- 线程问题。急!来者有分!
- (急)白痴问题一个——怎么更改windows里的默认字体?
- Unixtime问题
- 请高手指点迷津
- 我想拦截用户点窗体的X(关闭),使用户点X(关闭)时,相当于点“最小化”按钮,不知道该怎么办
- 请问各路大虾,那里有详细的函数、事件和属性的说明!
- qt无法显示背景图片
- Delphi7 安装时总是出现一个错误提示, 求助!
- 【反编译DCU得到源代码】不知道这是不是真的,如果真的。。。
把ADOQuery的ExcuteOption属性设为 eoAsyncFetch, 再在FetchProgress 中写代码 procedure TForm1.ADODataSet1FetchProgress(DataSet: TCustomADODataSet; Progress, MaxProgress: Integer; var EventStatus: TEventStatus);
begin
Caption := 'Percent complete: ' +
IntToStr(Trunc(Progress / MaxProgress * 100)) + '% ';
Application.ProcessMessages;
end;