with database1 do
begin
LoginPrompt:=false;
Connected:=false;
Params.Clear;
Params.Add('Database Name='+YourAccessDatabase);
Params.Add('Password='+GetAccessPass(YourAccessDatabase));
Connected:=true;
end;
//解出Access密码.
function GetAccessPass(FileName:string):string;
begin
.
.
.
end;
将的我东西复制给你,别讲你不会呀,我的东西都存在注册表里的
你可以不必理会,只须从我的号地方看起即可,但你必将其loginprompt设为false,
database控件的connect设为 false;
procedure TDataModule1.TDataModule1Create(Sender: TObject);
var
L_maxid:Integer;
DatabaseUserid,DatabasePassword:String;
begin
DatabaseUserid:=FindRegKeyString(REG_ROOTKEY,REG_SOFTWAREFOLDER+'\Database','UserID');
if Length(DatabaseUserid)=0 then
begin
WriteRegKeyString(REG_ROOTKEY,REG_SOFTWAREFOLDER+'\Database','UserID','');
end;
DatabasePassword:=FindRegKeyString(REG_ROOTKEY,REG_SOFTWAREFOLDER+'\Database','Password');
if Length(DatabasePassword)=0 then
begin
WriteRegKeyString(REG_ROOTKEY,REG_SOFTWAREFOLDER+'\Database','Password','password');
end;
***************************************
DataBase1.Params.Add('USER NAME='+DatabaseUserid);
DataBase1.Params.Add('PASSWORD='+DatabasePassword);
try
DataBase1.Connected:=True;
except
Application.Terminate;
end;
CheckXZDatabase();
if Not Login() then Application.Terminate;
with TQuery.Create(Self) do
begin
Close;
DatabaseName:=DatabaseAlias;
SQL.Clear;
SQL.Add('select * from sz_jbxx');
Open;
if RecordCount=0 then
begin
L_maxid:=INCID('sz_jbxx');
SQL.Clear;
SQL.Add('insert into sz_jbxx (id,sz_jbxx_dwmc) values('+IntToStr(L_maxid)+','''')');
ExecSQL;
PUBLIC_DWMC:='';
end
else
begin
PUBLIC_DWMC:=FieldByName('sz_jbxx_dwmc').AsString;
end;
Free;
end;
tb_ryxx.Active :=true;
tb_ryzp.Active :=true;
tb_rysy.Active :=true;
tb_zzry.Active :=true;
tb_txry.Active :=true;
tb_bm.Active :=true;
tb_lsry.active:=true;
TB_lxry.active:=true;
tb_ctry.Active :=true;
tb_rykq.active:=true;
tb_kqgz.Active :=true;
tb_xz_xm.Active :=true;
tb_xm_sz_xx.active:=true;
tb_rs_ht.Active:=True;