数据库的恢复时总是会有一些预想不到的错误,我写了一个高级先项,将数据库的一些参数据填入,但还是不能解决
解决方案 »
- 好久不来了,发个个性帖嘿嘿~~
- 请求各位大人解答一下如何才在三层架构中调用中间层中的函数呢???
- 哪位知道:AutoCad中,用鼠标拉出一个区域,然后对其进行放大,是怎么做的??在线等待
- vb delphi vc++ java mysql sql server oracle
- 要求imgage自动出现水平或垂直滚动条?
- 简单问题?
- 服务程序里不能调用ShellExcute吗?
- 请问nmsmtp:=TNMSMTP(NMSMTP)在执行中为何报错?在线等,谢谢
- 我手上有一张delphi6的安装盘,如何提取某些控件到delphi5中?急救!!!11
- 让我们改变字段!
- 怎样得到和修改显示器的分辩率
- ado补丁下载网址
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, ExtCtrls, DBCtrls, StdCtrls, XP_Button, DB, Mask,
ComCtrls, ADODB, ProgressCyl,INIFiles, XP_Form;type
TDBBackupForm = class(TForm)
XP_Form1: TXP_Form;
Label1: TLabel;
pgbar: TProgressCyl;
XP_Button1: TXP_Button;
XP_Button2: TXP_Button;
XP_Button3: TXP_Button;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
ADOCommand1: TADOCommand;
procedure XP_Button1Click(Sender: TObject);
procedure XP_Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure XP_Button3Click(Sender: TObject);
private
SYSINI: TINIFile;
DevName,TmpStr,InitDB:String;
strlen:Integer;
public end;var
DBBackupForm: TDBBackupForm;implementationuses DataModule_Unt;
{$R *.dfm}procedure TDBBackupForm.XP_Button1Click(Sender: TObject);
begin
close;
end;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;end.
全部的代码