在密码的Edit2的OnEnter事件中写 Query1.Active:=False;
Query1.Sql.Clear;
Query1.sql.add('select * from user where Name='#39+edit1.text+#39);
Query1.active:=True;
if query1.recordcount<=0 then
showmessage('No this User'+' '+edit1.text);
Query1.Sql.Clear;
Query1.sql.add('select * from user where Name='#39+edit1.text+#39);
Query1.active:=True;
if query1.recordcount<=0 then
showmessage('No this User'+' '+edit1.text);
解决方案 »
- 请教一个关于Tchart显示坐标的问题,看怎样实现下面的功能?
- 如何设置 IDTCPCLIENT 与IDTCPSEVER 的IP .
- 请问delphi有没有关机,重启,注销之类的函数?
- 关于mysql的问题!!!!!!!!!!!!!!
- 请教ActiveSkin如何用?(200分相送)
- delphi中一个奇怪的问题?
- 来学习DELPHI,请推荐例子下载网站。
- 讨论B/S架构的实现。http://www.wecoo.com是如何实现的?用ASP+Delphi5能做出来吗?
- 小鸟继续求助:使自己的程序在系统后台运行,无论在桌面还是系统托盘都看不见 !!!
- 用甲猫拨乙猫,怎样才能通过delphi在程序中知道,乙猫是否被拨通,或乙猫的状态,谢谢
- 请问一个简单的条件是用Ttable的filter还是Tquery?
- 怎么用OLE实现与手机的通讯??
如果以这种方法判断的话,我不需要知道数据库中的任何用户名或密码便可登入。
begin
if key=#13 then
begin
with Query1 do
begin
Close;
SQL.Clear;
SQL.Add('Select *');
SQL.Add('From 表 别名');
SQL.Add('Where 条件');
ParamByName('cn').AsString:=UserEdit.Text;
Open;
if recordcount<>0 then PasswordEdit.SetFocus
else
begin
if MessageDlg('没有该用户!是否继续?',mtConfirmation,
[MBYes,MBNo],0)=mrYes then
begin
UserEdit.Clear;
UserEdit.SetFocus;
end;
end;
Close
end;
end;
end;
'select * from user where Name='#39+edit1.text+#39 + ' and password='#39+edit2.txt+#39
1 是否把代码放在 Username 控件的 OnExit 事件上,这样只要焦点离开了UserName输入区
就执行核查,逻辑上更好一些,我这么认为的,:-)
2 Query1.sql.add('select count(Name) from user where Name='#39+edit1.text+#39);
Query1.active:=True;
if query1.Fields[0].AsInteger = 0 then
showmessage('No this User'+' '+edit1.text);
这样就不用将整条记录返回来了,只需要取回感兴趣的内容就可以了...