如题!如果有详细解释和代码可以还加分。
解决方案 »
- 在win98下如何新建拨号连接,用程序实现,注意是新建一个连接,急,要多少分给多少只要我有分
- 让RadioButton被选中的问题
- Delphi 编写的Dll怎样在Window2000下注册
- 如何按下回车键就退出该循环?
- 如何在程序中直接链接一个ftp地址?
- 我已经提了三问了:应用程序调用DLL,DLL是一个窗体,按Tab键,怎么实现DLL和应用程序的焦点切换.
- 请问一个关于事物控制更新问题?
- Exception Eolesyserror in modue ***.exe 类没有注册。
- 急,急,急用datetimepicker控件控制时间段?
- Delphi与Unix下的数据库
- 请大家看看在我的这个类中如何读写数组属性?
- 有开发过IC卡(医疗保险)程序经验的哥们请进。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TFlatGaugeUnit, StdCtrls, TFlatEditUnit, ExtCtrls,FileCtrl;type
TBackup_F = class(TForm)
Label1: TLabel;
Label2: TLabel;
ZT_FE: TFlatEdit;
JD_FG: TFlatGauge;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Backup_F: TBackup_F;implementation{$R *.dfm}Uses
ExtIniFiles,StrUtils;function GetFileNum(dir:string):integer;
var
sr:Tsearchrec;
begin
result:=0;
if findfirst(dir,faanyfile,sr)=0 then
repeat
if(sr.Attr<>fadirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
result:=result+1;
until findnext(sr)<>0;
end;
//***********************************************************************************
procedure Wait(second:Longint);
var
FirstTickCount:longint;
begin
FirstTickCount:=GetTickCount;
repeat
Application.ProcessMessages;
until ((GetTickCount-FirstTickCount) >=second);
end;
//***********************************************************************************
procedure TBackup_F.Timer1Timer(Sender: TObject);
var
myini:TExtIniFile;
cz,num:integer;
spath,dpath,name,RQ:string;
sr:Tsearchrec;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
Timer1.Enabled:=false;
myini:=TExtIniFile.Create(ExtractFilePath(Application.ExeName)+'set.ini');
cz:=myini.ReadInteger('bakup','CZ',0);
if cz=0 then
begin
spath:=ExtractFilePath(Application.ExeName)+'Data';
dpath:=myini.ReadString('bakup','BakPath','');
dpath:=dpath+'\'+AnsiReplaceStr(DateTimeToStr(now),':','');
ForceDirectories(dpath);
num:=GetFileNum(spath+'\*.*');
ZT_FE.Text:='正在备份数据库......';
JD_FG.MaxValue:=num;
if findfirst(spath+'\*.*',faanyfile,sr)=0 then
repeat
if(sr.Attr<>fadirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
begin
copyfile(pchar(spath+'\'+sr.Name),pchar(dpath+'\'+sr.Name),false);
JD_FG.Progress:=JD_FG.Progress+1;
end;
Wait(100);
until findnext(sr)<>0;
ZT_FE.Text:='数据库备份成功';
MessageBox(handle,'恭喜你:数据库备份成功!','祝贺你',MB_OK or MB_ICONINFORMATION);
end
else begin
RQ:=myini.ReadString('bakup','RQ','');
spath:=myini.ReadString('bakupdian',RQ,'');
spath:=spath+'\'+RQ;
dpath:=ExtractFilePath(Application.ExeName);
dpath:=dpath+'Data';
num:=GetFileNum(spath+'\*.*');
ZT_FE.Text:='正在还原数据库......';
JD_FG.MaxValue:=num;
if findfirst(spath+'\*.*',faanyfile,sr)=0 then
repeat
if(sr.Attr<>fadirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
begin
copyfile(pchar(spath+'\'+sr.Name),pchar(dpath+'\'+sr.Name),false);
JD_FG.Progress:=JD_FG.Progress+1;
end;
Wait(100);
until findnext(sr)<>0;
ZT_FE.Text:='数据库还原成功';
MessageBox(handle,'恭喜你:数据库还原成功!','祝贺你',MB_OK or MB_ICONINFORMATION);
end;
StartupInfo.cb:=sizeof(StartupInfo);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
CreateProcess(pchar(ExtractFilePath(Application.ExeName)+'TSGL.exe'),nil,nil,nil,false,0,nil,nil,StartupInfo,ProcessInfo);
close;
end;end.
至于检测系统是否安装SQL SERVER,做一界面提示输入用户名、密码、服务器名等信息,然后连接一下不就可以了吗
实现是可以的
看看install shield的帮助吧
指定数据文件的位置;
用打包工具将数据文件拷贝到目标位置;
再写代码将数据文件附加到SQL SERVER中(用sp_attach_db存储过程可以实现);
当然前提是目标机器的SQL SERVER服务是开启的.
begin
pgbar.Max:=100;
pgbar.Min:=0;
pgbar.Step:=20;
try
ADOCommand1.CommandText:='use master ';
pgbar.StepIt;
pgbar.StepIt;
adocommand1.Execute ;
adocommand1.CommandText:='RESTORE database docmanage FROM DISK = ''c:\back.bak'' with replace ';
pgbar.StepIt; pgbar.StepIt;
pgbar.StepIt;
adocommand1.Execute ;
try
aDOConnection1.Connected:=true;
except
ShowMessage('无法连接指定的数据库!');
application.Terminate;
end;
form1.Hide;
if messagedlg('c:\back.bak已成功还原到数据库docmanage!继续?',mtwarning,[mbok],0)=mrok then
begin
form2.close
end;
except
on exception do
if ADOConnection1.InTransaction then
ADOConnection1.RollbackTrans;
end;
end;
end;