你可以做一个登入界面,
用户名edit1,密码框edit2.PasswordChar:='*';opendialog1,一个用来确定的button1
procedure TForm1.Button1Click(Sender: TObject);
var
spath:string;
begin
if opendialog1.Execute then
if opendialog1.FileName<>'' then
begin
spath:= opendialog1.FileName;
ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Password='
+edit2.text+';User ID='+edit1.text+';Persist Security Info=True;Data Source='+spath;
...
end;
end;
procedure Tfrmpass.FormCreate(Sender: TObject);
var
spath:string;
begin
spath:=extractfilepath(application.ExeName )+'yp_data.mdb';
ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source='+ spath;
adoconnection1.loginprompt:=false;
adoconnection1.connected:=true;
adocommand1.commandtext:='select * from user_info';
adocommand1.commandType:=cmdText;
adodataset1.recordset:=adocommand1.execute;
while not adodataset1.recordset.eof do begin
co.items.add(adodataset1.recordset.fields['user_name'].value);
adodataset1.recordset.movenext;
end
end;