procedure Tfrm_login.Button2Click(Sender: TObject);
var
sqlstr:string;
begin
sqlstr:='select * from qx where 账号='+edt_id.Text+' and 密码='+edt_pw.Text+' and 权限=系统管理员';
adoquery1.Close;
adoquery1.SQL.Add(sqlstr);
adoquery1.Open;
if adoquery1.RecordCount<>0 then
begin
frm_user.Show;
end
else
begin
showmessage('你没有权限');
end;
end;
报错操作符丢失和参数账号没有默认值,为什么,望哪位高手改写一下,不胜感激。
急用

解决方案 »

  1.   

    字符串是要用引号括起来的sqlstr:='select * from qx where 账号='''+edt_id.Text+''' and 密码='''+edt_pw.Text+''' and 权限=''系统管理员''';
      

  2.   

    sqlstr:='select * from qx where 账号='+QuotedStr(Edt_id.tet)+' and 密码='+QuotedStr(edt_pw.Text)+' and 权限='+QuotedStr(系统管理员);
      

  3.   

    function QuotedStr(const S: string): string;
    功能:字符串S开始和结尾都添加一个引用字符串',如果中间有',则在其前面添加一个'。
    说明:s:要转化的字符串,返回值:加引用串后的字符串;
    用法:Table1.Open;
          Table1.Filter :='Name='+QuotedStr('foxyy8888');//Name:字符型字段。
          Table1.Filtered :=True;
    ===========================================================================
    其实和 ehom(?!) 老大的功能是一样的。只是这样更简洁易懂。