才从VB转到Delphi
看了不少关于登录密码验证的方法,用query控件,Filter...试了一下 都没成功各位大虾能总结下吗>?(D7+ADO+SQL SERVER2k)

解决方案 »

  1.   

    ...adoquery1.sql.clear;
    adoquery1.sql.add('select count(*) as cc from xxx where id='''+edit1.text+''' and pwd='''+edit2.text+'''');
    adoquery1.close;
    adoquery1.open;
    if adoquery1.fieldbyname('c').asinteger=0 then
      不通过
    else
      通过
      

  2.   

    改:
    if adoquery1.fieldbyname('c').asinteger=0 then  --->
    if adoquery1.fieldbyname('cc').asinteger=0 then
      

  3.   

    对了,我对filter得用法还不是狠清楚
    怎么是四个''''  ?
      

  4.   

    你用showmessage('''');看看就明白了,其中一个是转义用的,两个是delphi字符串开始结束用的,只有一个是真的'
      

  5.   

    楼上的登陆验证都有问题,容易受到sql的攻击,假如有人把密码输入为xxx'' or ''1=1,那你完了,随便登陆啊
      

  6.   

    谢了哈jinjazzADOConnection1.Connected:=True;
    table.filter:='ID='''+edit1.text+'''';
    table.filter:=true;
    table.open;if table.RecordCount=1 then
    ....这么也行吗?
      

  7.   

    《〈楼上的登陆验证都有问题,容易受到sql的攻击,假如有人把密码输入为xxx'' or ''1=1,那你完了,随便登陆啊agree!这只是个示范,楼主上面的也正确