L
luckandy
Unregistered / Unconfirmed
GUEST, unregistred user!
請問各位大俠,如何用下面的代碼備份時,如何實現網絡備份(客戶端),客戶端備份
服務器數據庫資料。
procedure TFormbackup.Button1Click(Sender: TObject);
var
f: textfile;
names,comm,database,date,path,myfile,medium,fline: string;
begin
myfile:=extractfilepath(application.ExeName)+'data/login.ini';
assignfile(f,myfile);
reset(f);
readln(f,fline);
database:=copy(fline,pos('=',fline)+1,20);
names:=edit1.text;
date:=edit2.text;
path:=fileedit1.text;
if radiogroup2.ItemIndex=0 then
medium:='disk'
else
medium:='tape';
with datamod do
try
begin
pbar1.max:=1;
pbar1.position:=0;
pbar1.step:=1;
query1.close;
query1.sql.text:='exec sp_addumpdevice '''+medium+''','''+names+''','''+path+''' ';
query1.sql.SaveToFile('c:/xx.sql');
query1.execsql;
if RadioGroup1.ItemIndex=0 then
comm:='backup database '+database+' to '+names+' with noinit,nounload,noskip,stats='+date+',noformat,name='''+names+''''
else
comm:='backup log '+database+' to '+names+' with noinit,nounload,noskip,stats='+date+',noformat,name='''+names+'''' ;
with datamod.ADOCommand1 do
begin
CommandText:=comm;
label1.caption:='';
label1.update;
pbar1.stepit;
Execute;
application.messagebox('資料備份已完成!','備份成功',mb_ok+mb_iconinformation);
close;
end;
end;
except
application.messagebox('你輸入的資料名或備份路徑資料名已存在!.','相同資料名',mb_ok+mb_iconerror);
end;
end;
procedure TFormbackup.RadioGroup1Enter(Sender: TObject);
begin
if RadioGroup1.ItemIndex=0 then
begin
edit2.text:='1';
edit1.text:='D'+formatdatetime('yymmddhhn',now);
end
else
begin
edit2.text:='6';
edit1.text:='C'+formatdatetime('yymmddhhn',now);
end ;
end;
procedure TFormbackup.FormActivate(Sender: TObject);
begin
edit2.text:='6';
edit1.text:='C'+formatdatetime('yymmddhhn',now);
end;
procedure TFormbackup.Edit1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
fileedit1.text:=edit1.text;
end;
服務器數據庫資料。
procedure TFormbackup.Button1Click(Sender: TObject);
var
f: textfile;
names,comm,database,date,path,myfile,medium,fline: string;
begin
myfile:=extractfilepath(application.ExeName)+'data/login.ini';
assignfile(f,myfile);
reset(f);
readln(f,fline);
database:=copy(fline,pos('=',fline)+1,20);
names:=edit1.text;
date:=edit2.text;
path:=fileedit1.text;
if radiogroup2.ItemIndex=0 then
medium:='disk'
else
medium:='tape';
with datamod do
try
begin
pbar1.max:=1;
pbar1.position:=0;
pbar1.step:=1;
query1.close;
query1.sql.text:='exec sp_addumpdevice '''+medium+''','''+names+''','''+path+''' ';
query1.sql.SaveToFile('c:/xx.sql');
query1.execsql;
if RadioGroup1.ItemIndex=0 then
comm:='backup database '+database+' to '+names+' with noinit,nounload,noskip,stats='+date+',noformat,name='''+names+''''
else
comm:='backup log '+database+' to '+names+' with noinit,nounload,noskip,stats='+date+',noformat,name='''+names+'''' ;
with datamod.ADOCommand1 do
begin
CommandText:=comm;
label1.caption:='';
label1.update;
pbar1.stepit;
Execute;
application.messagebox('資料備份已完成!','備份成功',mb_ok+mb_iconinformation);
close;
end;
end;
except
application.messagebox('你輸入的資料名或備份路徑資料名已存在!.','相同資料名',mb_ok+mb_iconerror);
end;
end;
procedure TFormbackup.RadioGroup1Enter(Sender: TObject);
begin
if RadioGroup1.ItemIndex=0 then
begin
edit2.text:='1';
edit1.text:='D'+formatdatetime('yymmddhhn',now);
end
else
begin
edit2.text:='6';
edit1.text:='C'+formatdatetime('yymmddhhn',now);
end ;
end;
procedure TFormbackup.FormActivate(Sender: TObject);
begin
edit2.text:='6';
edit1.text:='C'+formatdatetime('yymmddhhn',now);
end;
procedure TFormbackup.Edit1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
fileedit1.text:=edit1.text;
end;