在用户登陆的时候,输入用户名和密码,通过用户名确定为管理员还是普通用户,我用什么函数提取数据库里面的type字段的值啊?请举个例子吧!谢谢大家!

解决方案 »

  1.   

    ADOconnection1.ConnectionString:='数据库连接字符串';
    ADOconnection1.Open;
    ADOquery1.Connection:= ADOconnection1;
    ADOquery1.SQL.Clear;
    ADOquery1.SQL.Add('根据用户名和密码查询出你想要的字段,当然要包括 type');
    ADOquery1.Open;
    通过
    ADOquery1.FieldByName('type').Value; 
    这样子来获得 type 的值
      

  2.   

    var
      lx:string;
    begin
      adoquery1.close;
      adoquery1.sql.text := 'select type from usertbl where Userid=''ID001''';//查找用户编号为“ID001”的用户类型
      adoquery1.open;
      if adoquery1.RecordCount> 0 then
        lx:= adoquery1.fieldbyname('type').asstring
      else
        messagebox(SELF.Handle,'系统中没有该用户编号!','警告!',MB_ICONSTOP);
    end;
      

  3.   

    用这个 ADOQuery1.FieldByName('type').asString 来获取结果
      

  4.   

    ADOQuery1.FieldByName('Type').Value:= Trim(Edit1.text);