郁闷死了,想做了身份验证的界面,怎么业做不好,谁能帮帮我????
解决方案 »
- 关于最小化到拖盘的问题
- 如何在登陆时显示上一次登陆的用户名?
- 如何使用fastreport自动换行,左右对齐的问题!
- 乱码问题,怎么一直没人回答,是不是没有人碰到过啊
- 各位大哥谁用过Interbase数据库,如何用Sql Explor打开gdb表?
- 问完这个问题又没分了,怎么总是一贫如洗,请问,怎么可以让一个DBGrid不能获得焦点,点它不发任何反应?
- 怎么样在quickrep里面使用其它窗体中的变量或者edit的内容!!!
- 如何画矢量线?并且这个或者这些矢量线是可以编辑的。
- 小数点国际化问题
- 紧急求助,各位Delphi高手,数据的导入与导出
- CheckBrowseMode一般在什么时候下用。我好象很少用?哪位说说
- 如何连接有密码的Access?
如果是adoquery
adoquery.close;
adoquery.sql.clear;
adoquery.sql.add('select * from tablename');
adoquery.open;
先判断记录集(adoquery.recordcount)是否为1
然后再判断密码是否正确
adoquery.sql.add('select * from tablename where id=:uname');
adoqueryParameters.ParamByName('uname').Value:=uid.text;
function login(UserName,UserPwd:string):Boolean;
begin
ADoquery.close;
ADOQuery.sql.clear;
ADOQuery.sql.add('select * from yh where uname=.. and upwd=..');//自己处理一下
ADOQuery.open;
if ADoquery.eof then result:=false else true;
end;在用户点击了登录后:
if Login(A,B) then
//进入下一界面
else
abort;
adodataset1.commontest := format('select * from table where ''%s'',''%s''',[ID,PASWORD];
adoDataSet1.openif AdoDataset.recordcount <> 0 then
验证通过
else
失败
try
database1.Connected :=true;
user.Filter :='user='''+edit1.Text+'''';
user.Filtered :=true;
user.Open ;
except
application.MessageBox('请与管理员联系。','数据库联接错误!',0+MB_ICONINFORMATION);
application.Terminate ;
end;
if user.RecordCount =1 then
begin
if user['user']=edit1.Text then
begin
if user['mm']=edit2.Text then
begin
form1.Hide ;
form2.Show ;
end;
end;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.Text :='';
edit2.Text :='';
end;
beginif fileexists(extractfilepath(application.exename)+'yh.mdb') then
begin
//连接数据库字串
connstr:='Provider=Microsoft.Jet.OLEDB.4.0;data Source='+extractfilepath(application.exename)+'yh.mdb';
//建立Connection
conn:=CreateOleObject('ADODB.Connection');
//打开连接
conn.open(connstr);
rs:=CreateOleObject('ADODB.Recordset');
rs.open('select * from tuser order by userid',conn,1,1);
if not rs.eof then
begin
rs.movefirst;
repeat
cbUser.Items.Add(rs.fields.Item['username'].value);
rs.movenext;
until rs.eof;
end;
rs.close;
rs:=unassigned;
end
else
begin
showmessage('找不到数据库文件,程序即将结束');
Login:=false;
close;
end;end;procedure TfrmLogin.btnOkClick(Sender: TObject);
begin
if count>=3 then
begin
showmessage('对不起,您无权进入本系统,程序即将结束!');
login:=false;
close;
exit;
end;
rs:=CreateOleObject('ADODB.Recordset');
rs.open('select * from tuser where username='+yinhao+trim(cbuser.Text)+yinhao,conn,1,1);
if not rs.eof then //用户存在,判断密码
begin
UserInfoA.UserID:=rs.fields.Item['UserID'].value;
UserInfoA.UserName:=rs.fields.Item['UserName'].value;
UserInfoA.Password:=rs.fields.Item['pass'].value;
UserInfoA.Level:=rs.fields.Item['Level'].value;
UserInfoA.Gtdm:=rs.fields.Item['Gtdm'].value;
rs.close;
rs:=unassigned;
end
else
begin
UserInfoA.UserID:=0;
UserInfoA.UserName:='';
UserInfoA.Password:='';
UserInfoA.Level:=1000;
UserInfoA.Gtdm:=0;
end;if UserInfoA.UserName='' then
begin
inc(Count); //错误次数加一
showmessage('此用户不存在,请重新输入!');
cbuser.SetFocus;
exit;
end;if (UserInfoA.Password<>trim(edtpwd.Text)) and (UserInfoA.UserName=trim(cbuser.text)) then
begin
inc(Count); //错误次数加一
showmessage('密码错误,请重新输入!');
edtpwd.text:='';
edtpwd.SetFocus;
exit;
end;Login:=true;
close;end;procedure TfrmLogin.FormActivate(Sender: TObject);
begin
cbuser.SetFocus;
end;