当前位置:编程学习 > Delphi >>

delphi登陆界面代码

我的SQL的表中有个login的表,有yhm和yhmm,delphi的登录界面有两个edit和一个Button,哪位高手给个代码

补充:感谢啊……
		
答案:procedure TForm1.Button1Click(Sender: TObject);
var
s,a:string;           //s用户名a用户密码
begin
    adoquery1.Close;
    adoquery1.Active:=false;
    adoquery1.SQL.Clear;
    adoquery1.SQL.Add('select * from a');      //a数据库的数据表名
    adoquery1.Active:=true;
    adoquery1.Open;
    adoquery1.First;                              //查询用户名在数据表中对应的位置
    s:=adoquery1.FieldByName('yhm').AsString;
    s:=trim(s);
    if s=edit1.Text then
        begin
            a:=adoquery1.FieldValues['yhmm'];
            if (edit1.Text=s) and (edit2.Text=a) then
                begin
                    showmessage('正确');
                end
            else
                begin
                end;
            exit;
        end
    else
        begin
            repeat
                adoquery1.next;
                s:=adoquery1.FieldByName('yhm').AsString;
                s:=trim(s);
            until
                adoquery1.Eof or(s=edit1.Text);
        end;
    if (edit1.Text=s) and (edit2.Text=adoquery1.FieldValues['yhmm']) then
        begin
            showmessage('正确');
        end
    else
        begin
            showmessage('错误');
        end;
end;procedure TYhdlForm.sBitBtn1Click(Sender: TObject);
begin
sedit1.Text:=Enc(sedit1.Text);
adoquery1.Close;
adoquery1.SQL.Text:='select yhm from Y_yhb where yhm='+''''+scombobox1.Text+'''';
adoquery1.Open;
if not adoquery1.IsEmpty then
  begin
adoquery1.Close;
adoquery1.SQL.Text:='select mima from Y_yhb where mima='+''''+sedit1.Text+''''+'and yhm='+''''+scombobox1.Text+'''';
adoquery1.Open;
   if not adoquery1.IsEmpty then
   begin
    CzymForm.Show;
    YhdlForm.Hide;
   end
   else
   begin
   Messagebox(YhdlForm.Handle, '密码错误,请重新输入!', '密码错误提示', MB_OK + MB_ICONINFORMATION);
   sedit1.Clear;
   sedit1.SetFocus;
   end;
  end
  else
  Messagebox(YhdlForm.Handle, '不存在此帐号,请重新输入!', '帐号错误提示', MB_OK + MB_ICONINFORMATION);
end;

上一个:delphi sql语句出错
下一个:Delphi简单调用DLL

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,