各位,
请帮我看一下下面的代码,这个是设定菜单的权限的,但运行过后,可以进入程序,但所有的菜单是灰色的,不可以用。经过调试,我发现在g_result并没有值反回。
用户的菜单权限我已存在SQL2008中的数据库的表中,如果用户是999的话,应该是可以看到菜单啊?这个程序是从7.0版本升级到12.6版本的,在老版本上是可以实现的,但到新的不知为什么不可以了,问题出在哪里?
// Browse through Menu
menu_total1 = UpperBound(g_menu.Item)
for circle = 1 to menu_total1
cp_name = g_menu.Item[circle].ClassName()
// messagebox("", cp_name + gs_userid )
Select useright into :g_result from userright
where rtrim(userno) =:gs_userid and menuno = :cp_name Using SQLCA ;
Choose Case SQLCA.SqlCode
Case 0
if g_result = '1' then
g_menu.Item[circle].Enable()
else
if gs_userid = "999" then
g_menu.Item[circle].Enable()
else
g_menu.Item[circle].Disable()
end if
end if
case 100
g_menu.item[circle].Disable()
Case -1
MessageBox(parentwindow.title,"DataBase connect database fail!")
End Choose
End For
------解决思路----------------------
Select useright into :g_result from userright
where rtrim(userno) =:gs_userid and menuno = :cp_name Using SQLCA ;
这句没有返回值吗?
------解决思路----------------------
用debug模式查看
Select useright into :g_result from userright
where rtrim(userno) =:gs_userid and menuno = :cp_name Using SQLCA ;
的 gs_userid 與 cp_name 的值
知道這2個變量的值之後, 到 SQL Server Management Studio裏去測試是否有返回值
Select useright
from userright
where rtrim(userno) ='gs_userid值'
and menuno = 'cp_name值'