根据数据库中级别字段:当级别字段为系统管理员时增加删除扭钮为有效状态,当字段为其它时增加删除按扭为无效状态.
我的代码如下:
with adoqYhgl do
  begin
    Connection := AdoWzgl;
    SQL.Text := 'select U_name,U_level from users';
    Open;
    if (adoqYhgl.FieldByName('U_level')).Value  <> '系统管理员' then
    begin
     btadd.Enabled :=true;
     btdel.Enabled :=true;
    end;
  end;

解决方案 »

  1.   

    首先,你的Delphi代码怎么用双引号的呢?
    其实,你的代码应该差不多可以实现你想要的效果啊
    with   adoqYhgl   do 
        begin 
            Connection   :=   AdoWzgl; 
            SQL.Text   :=   'select   U_name,U_level   from   users Where U_name='''+'当前操作者的U_name'+''''; 
            Open; 
        end;//----下面这段不要放在With里面  btadd.Enabled:=adoqYhgl.FieldByName( 'U_level ').AsString='系统管理员'; 
      btdel.Enabled:=adoqYhgl.FieldByName( 'U_level ').AsString='系统管理员'; 
      

  2.   

    晕了,我发上来的代码也被CSDN自动搞成双引号的了
    冤枉楼主了
      

  3.   

    非常感谢1楼的朋友!
    我还想补充一下:我有两个界面,一个是登录界面一个是主界面, 在主界面上怎么加载登录界面中的数据表???SQL.Text       :=       "select       U_name,U_level       from       users   Where   U_name= " " "+ "当前操作者的U_name "+ " " ;   
    当前操作者的U_name  是怎么样获取的??