procedure Tfrm_login.bbtn_loginClick(Sender: TObject);
begin
  if cbo_user.text='' then
    begin
     application.messagebox('请选择登录用户','选择用户',mb_ok+mb_iconasterisk);
     cbo_user.SetFocus();
     exit;
    end;
 
   with datamodule1.ado_login do
   begin
    //try
     close;
     sql.Clear;
     sql.Add('select * from sys_user where username='+''''+cbo_user.text+'''');
     open;
    if not isempty then
     begin
      if edt_password.text<> fieldbyname('password').asstring then
        begin
          application.MessageBox('您输入的密码错误,请重新输入','输入密码',mb_ok+mb_iconstop);
          LoginNum:=loginnum+1;
        if loginnum=3 then
         begin
           application.messagebox('非法用户!您无权使用本系统','登录错误',mb_ok+mb_iconstop);
             application.Terminate ;
        end;
        edt_Password.Text :='';
        edt_Password.SetFocus;
        exit;
     end
     else
       begin
        gs_login_username   :=fieldbyname('username').asstring;
        gt_login_time:=datetostr(now());
        login:=true;
        frm_login.close;       end;
      end;
     end;
     end;
自己去看吧。