老问题:如何做一个假的数据库备份的进度条? 真的,不好做。。但如何做一个假的,或是类似的,?查询了一下经前的贴子,有人说先算出文件大小,然后估算出文件传送的时间,然后到了99%就等待。。这个文件传送的时间如何得到?哪位兄弟做过,请指教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用SHFileOperation,可以产生进度条 数据库备份呀?是'backup database.....'如何能用SHFileOperation呵呵。。 补充一下:是用AdoQuery来实现的。 SHFileOperation可以COPY、DELETE文件、目录,如你只是COPY数据库的话,可以用此函数。 感觉这个SHFileOperation不是很好用,在这里效果也不行。办法,还没有想到。 不是copy文件,是备份呀,对Sqlserver中的数据库的备份,怪我自己没有说清楚,呵呵。。Adoquery.SQL.Clear;Adoquery.SQL.Add('backup database ris to disk=........'); 用sql-dmo可以实现的。可源码是VC的,在msdn里,看不太懂呀。。 procedure TDBBackupForm.XP_Button2Click(Sender: TObject);begin pgbar.Max:=100; pgbar.Min:=0; pgbar.Position:=0; pgbar.Step:=20; With SaveDialog1 do begin filename:='DB'+FormatDateTime('yy_MM_dd_hh_mm_ss',Now); options:=[ofhidereadonly,offilemustexist,ofpathmustexist]; if execute then begin label1.Caption:='正在备份中...'; DataModule1.ADOConnection1.Close; TmpStr:= ExtractFileName(filename); strlen:= Length(TmpStr); DevName:= Copy(TmpStr,1,strlen-4); begin try ADOCommand1.CommandText:='use Master'; pgbar.StepIt; ADOCommand1.Execute; adocommand1.CommandText:='execute sp_helpdevice'; pgbar.StepIt; adocommand1.Execute ; pgbar.stepit; adocommand1.CommandText:='backup database '+InitDB+' to disk='''+filename+''' with init'; pgbar.StepIt; adocommand1.Execute ; adocommand1.CommandText:='Use '+InitDB; pgbar.StepIt; adocommand1.Execute ; Self.Hide; ShowMessage('数据库已经成功备份到 '+filename+'!'); Try DataModule1.ADOConnection1.Connected:= True; Except ShowMessage('无法重新接连数据库!,系统即将退出!'); Application.Terminate; End; self.Close; Except On Exception do if DataModule1.ADOConnection1.InTransaction then DataModule1.ADOConnection1.RollbackTrans; End; End; end; end;end;procedure TDBBackupForm.FormActivate(Sender: TObject);begin SYSINI := TIniFile.Create(ExtractFilePath(Application.ExeName)+'DB.INI'); try InitDB := SYSINI.ReadString('Database', 'InitDB', ''); finally SYSINI.Free; end;end;procedure TDBBackupForm.XP_Button3Click(Sender: TObject);begin pgbar.Max:=100; pgbar.Min:=0; pgbar.Position:=0; pgbar.Step:=20; With OpenDialog1 do begin filename:=''; options:=[ofhidereadonly,offilemustexist,ofpathmustexist]; if execute then begin label1.Caption:='正在还原中...'; DataModule1.ADOConnection1.Close; TmpStr:= ExtractFileName(filename); strlen:= Length(TmpStr); DevName:= Copy(TmpStr,1,strlen-4); pgbar.StepIt; try ADOCommand1.CommandText:='use Master'; ADOCommand1.Execute; pgbar.StepIt; adocommand1.CommandText:='execute sp_helpdevice'; adocommand1.Execute ; pgbar.stepit; adocommand1.CommandText:='Restore database '+InitDB+' From disk='''+filename+''' with replace'; pgbar.StepIt; adocommand1.Execute ; adocommand1.CommandText:='Use '+InitDB; pgbar.StepIt; adocommand1.Execute ; Self.Hide; ShowMessage('数据库已经成功还原到数据库 '+InitDB+'!'); Try DataModule1.ADOConnection1.Connected:= True; Except ShowMessage('无法重新接连数据库!,系统即将退出!'); Application.Terminate; End; self.Close; Except On Exception do if DataModule1.ADOConnection1.InTransaction then DataModule1.ADOConnection1.RollbackTrans; End; end; end;end; shengliqiang168(ValorSlq) 的方法不错。呵呵。。虽然是假的,可蛮像真的想做个真的,不容易,我搞了好几天,快疯掉了 发送图片到ASP问题 指针的运用 DELPHI群 打包 delphi制作可拖动的图形化流程制作工具 在二维表格中输入数据,如果不采用dbgrid,采用什么组件好呢?? 来看看我的问题 怎么样在DELPHI中调用DOS命令呢? 我的 sql2000+delphi做的管理软件有这样的问题…… 菜青虫的困难,大伙帮忙! 数据传输的安全性 如何在代码中创建一个word格式文件?(不是把word调出来)
是'backup database.....'
如何能用SHFileOperation呵呵。。
是用AdoQuery来实现的。
话,可以用此函数。
是备份呀,
对Sqlserver中的数据库的备份,怪我自己没有说清楚,呵呵。。Adoquery.SQL.Clear;
Adoquery.SQL.Add('backup database ris to disk=........');
看不太懂呀。。
begin
pgbar.Max:=100;
pgbar.Min:=0;
pgbar.Position:=0;
pgbar.Step:=20;
With SaveDialog1 do
begin
filename:='DB'+FormatDateTime('yy_MM_dd_hh_mm_ss',Now);
options:=[ofhidereadonly,offilemustexist,ofpathmustexist];
if execute then
begin
label1.Caption:='正在备份中...';
DataModule1.ADOConnection1.Close;
TmpStr:= ExtractFileName(filename);
strlen:= Length(TmpStr);
DevName:= Copy(TmpStr,1,strlen-4);
begin
try
ADOCommand1.CommandText:='use Master';
pgbar.StepIt;
ADOCommand1.Execute;
adocommand1.CommandText:='execute sp_helpdevice';
pgbar.StepIt;
adocommand1.Execute ;
pgbar.stepit;
adocommand1.CommandText:='backup database '+InitDB+' to disk='''+filename+''' with init';
pgbar.StepIt;
adocommand1.Execute ;
adocommand1.CommandText:='Use '+InitDB;
pgbar.StepIt;
adocommand1.Execute ;
Self.Hide;
ShowMessage('数据库已经成功备份到 '+filename+'!');
Try
DataModule1.ADOConnection1.Connected:= True;
Except
ShowMessage('无法重新接连数据库!,系统即将退出!');
Application.Terminate;
End;
self.Close;
Except
On Exception do
if DataModule1.ADOConnection1.InTransaction then
DataModule1.ADOConnection1.RollbackTrans;
End;
End;
end;
end;end;procedure TDBBackupForm.FormActivate(Sender: TObject);
begin
SYSINI := TIniFile.Create(ExtractFilePath(Application.ExeName)+'DB.INI');
try
InitDB := SYSINI.ReadString('Database', 'InitDB', '');
finally
SYSINI.Free;
end;end;procedure TDBBackupForm.XP_Button3Click(Sender: TObject);
begin
pgbar.Max:=100;
pgbar.Min:=0;
pgbar.Position:=0;
pgbar.Step:=20;
With OpenDialog1 do
begin
filename:='';
options:=[ofhidereadonly,offilemustexist,ofpathmustexist];
if execute then
begin
label1.Caption:='正在还原中...';
DataModule1.ADOConnection1.Close;
TmpStr:= ExtractFileName(filename);
strlen:= Length(TmpStr);
DevName:= Copy(TmpStr,1,strlen-4);
pgbar.StepIt;
try
ADOCommand1.CommandText:='use Master';
ADOCommand1.Execute;
pgbar.StepIt;
adocommand1.CommandText:='execute sp_helpdevice';
adocommand1.Execute ;
pgbar.stepit;
adocommand1.CommandText:='Restore database '+InitDB+' From disk='''+filename+''' with replace';
pgbar.StepIt;
adocommand1.Execute ;
adocommand1.CommandText:='Use '+InitDB;
pgbar.StepIt;
adocommand1.Execute ;
Self.Hide;
ShowMessage('数据库已经成功还原到数据库 '+InitDB+'!');
Try
DataModule1.ADOConnection1.Connected:= True;
Except
ShowMessage('无法重新接连数据库!,系统即将退出!');
Application.Terminate;
End;
self.Close;
Except
On Exception do
if DataModule1.ADOConnection1.InTransaction then
DataModule1.ADOConnection1.RollbackTrans;
End;
end;
end;end;