1.制作安装程序可以使用InstallShield for delphi
2.我的每个系统都是引用这个unit解决连接问题,基本上只需要设置system.ini文件就可以了.不用维护如何连接数据库.并且不用配置BDE. 另外,创建数据库也可以将SQL语句写到txt文件中,使用query.loadfromfile调用就可以了,如果需要加密,那么就自己做一个自定义格式的文件吧.
// ******************************************* //
// Database Connect Utility
//
// Copyright (c) 2000 by Ghsoft
//
// Written by Eric Gong 2000.05
//
// ******************************************* //
//Function : Change Database connectoin
//Params : db :Tdatabase
//Return Value: Boolean
//sample: if ChangeAccount(db_mis) then do {something about database db_mis} ;
Function ChangeAccount(var db:TDatabase):Boolean;
var
sAcctTitle:String;
begin
with TfrmAccount.Create(nil) do
begin
FDB:= @db;
FINIFile:= TINIFile.Create(ExtractFilePath(Application.exename)+'system.ini');
fIniFile.ReadSection('Account',cbxAcct.Items);
sAcctTitle:= fIniFile.readString('Login','Account','Data');
cbxAcct.ItemIndex:= cbxAcct.Items.IndexOf(sAcctTitle);
GetAccountDetail(fInifile.Readstring('Account',sAcctTitle,''));
showmodal;
Result:= modalResult = mrOK;
if Result then fIniFile.WriteString('Login','Account',cbxAcct.text);
fIniFile.Free;
Free;
end;
end;
procedure TfrmAccount.SetFormstate(Value:Tformstate);
begin
if FFormState <> Value then
begin
FFormState := Value;
case Value of
fsSimple : begin CmdDetail.Caption:= '冈灿 >>'; Height := 120; end;
fsDetail : begin CmdDetail.Caption:= '<< 虏て'; Self.Height := 225; end;
end;
end;
end;
Function TfrmAccount.Getformstate:Tformstate;
begin
Result:= FFormState;
end;
procedure TfrmAccount.FormCreate(Sender: TObject);
begin
FormState:= fsSimple;
end;
procedure TfrmAccount.CmdDetailClick(Sender: TObject);
begin
if formstate = fsDetail then formstate := fsSimple else formstate := fsDetail;
end;
procedure TfrmAccount.CmdOKClick(Sender: TObject);
begin
modalResult:= mrNone;
with FDb^ as TDatabase do
begin
connected:= False;
params.clear;
Params.Add('SERVER NAME='+edServer.Text);
Params.Add('DATABASE NAME='+fInifile.ReadString(fInifile.Readstring('Account',cbxAcct.Items[cbxAcct.ItemIndex],''),'DATABASE NAME','MASTER'));
Params.Add('USER NAME='+edUser.Text);
Params.Add('PASSWORD='+edPassword.Text);
Connected:= True;
end;
modalResult:= mrOK;
end;
procedure TfrmAccount.cbxAcctChange(Sender: TObject);
begin
GetAccountDetail(fInifile.Readstring('Account',cbxAcct.Items[cbxAcct.ItemIndex],''));
end;