【delphi开源代码栏目提醒】:网学会员为需要delphi开源代码的朋友们搜集整理了DBRestore_Unit.pas相关资料,希望对各位网友有所帮助!
unit DBRestore_Unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DB, ADODB, IniFiles;
type
TfrmDBRestore = class(TForm)
edtFilePath: TEdit;
SpeedButton1: TSpeedButton;
btnCancel: TBitBtn;
GroupBox1: TGroupBox;
lblHint: TLabel;
OpenDialog: TOpenDialog;
btnExecDBRestore: TBitBtn;
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure btnExecDBRestoreClick(Sender: TObject);
private
{ Private declarations }
public
end;
var
frmDBRestore: TfrmDBRestore;
implementation
uses DM_Unit;
{$R *.dfm}
procedure TfrmDBRestore.FormShow(Sender: TObject);
begin
lblHint.Caption := '提示:选择程序目录下数据库文件或者'+#13+'备份文件夹中的数据库文件并测试连接!';
end;
procedure TfrmDBRestore.SpeedButton1Click(Sender: TObject);
begin
with OpenDialog do
begin
InitialDir := ExtractFileName(Application.ExeName);
Filter := '*.mdb文件|*.mdb|*.bak文件|*.bak';
if Execute then
edtFilePath.Text := OpenDialog.FileName;
end;
end;
procedure TfrmDBRestore.btnExecDBRestoreClick(Sender: TObject);
var
IniFile: TIniFile;
DBFileName: string;
begin
IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'Config.ini');
try
DBFileName := IniFile.ReadString('DBConn', 'ConnString', '');
finally
IniFile.Free;
end;
try
if edtFilePath.Text <> '' then
begin
DM.ADOConn.Connected := False;
if CopyFile(PChar(edtFilePath.Text), PChar(DBFileName), False) then
begin
DM.ADOConn.Connected := True;
Application.MessageBox('数据恢复成功!','提示',mb_ok + mb_IconInformation);
end;
end;
except
Application.MessageBox('数据恢复失败!','提示',mb_ok + mb_IconError);
end;
end;
end.
上一篇:
dblinkfrmUnit4.pas
下一篇:
心力衰竭的中医证素及常见证型