还有一个问题就是,我的管理员的表里面有三个字段,收费员,密码,级别
我想在主界面上根据登录的收费员的级别控制对应操作,我的级别是char类型的,下面是级别是0的时候,给予权限,该怎么改阿
If fLogin.OK Then
 sq1 = "select 级别  from  收费员 where 收费员='" & fLogin.txtUserName.Text & "' "
 Set rec = cnn.Execute(sq1)
 If Trim(rec.Fields(0)) = " 0" Then
   conditionqur.Enabled = True
End If
End If有人建议改为
....
dim ss
 ss = rec("级别")
If ss = 0 Then
   manaualcharge.Enabled = True
   xiugai.Enabled = True
   chargelogin.Enabled = True
End If
还是不行,大侠有什么意见?

解决方案 »

  1.   

    sq1 = "select 级别  from  收费员 where 收费员='" & fLogin.txtUserName.Text & "' "
    你的fLogin.txtUserName.Text 是從登錄窗体fLogin而來,此時flogin已關閉的話,是取不到值的.
    在模塊中定義一全局變量public username as string
    在fLogin登錄時,把登錄的用戶名賦值於username=txtUserName.Text 
    把sq1 = "select 级别  from  收费员 where 收费员='" & fLogin.txtUserName.Text & "' "
    改成
    sq1 = "select 级别  from  收费员 where 收费员='" & username & "' "
      

  2.   

    username的引用问题已解决,可是还是不对,  我把级别的类型改为int了,
    sq1 = "select 级别  from  收费员 where 收费员='" & username & "' " Set rec = cnn.Execute(sq1)
     If Trim(rec.Fields(0)) = 0 Then
       conditionqur.Enabled = True
    End If这样为什么不对啊?
      

  3.   

    Trim(rec.Fields(0)) = 0?级别的类型改为int了,rec.Fields(0) = 0。
    另外,级别的类型是char时,rec.Fields(0)应该是有几个空格的吧?!
      

  4.   

    就int类型了,rec.Fields(0) = 0,这样也不对啊
      

  5.   


     你先watch一下 rec.Fields(0) 的值就是多少,
      贴出来看看。
      

  6.   

    对,你的rec.Fields(0)不会是NULL吧??