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;不要忘记给分,或者到http://cnboor.com注册一下
你可以做一个登入界面, 用户名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;
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;不要忘记给分,或者到http://cnboor.com注册一下
我发现access设置密码后使用起来不方便,可不设置数据文件有不安全
谁有什么建议吗?
ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Password=密码;User ID=用户名;Persist Security Info=True;Data Source='+spath
用户名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;