经典的asp记录集权限问题
我正在尝试使用下面的 sql 字符串返回特定列的值,如果我将其更改为 sql = "select * from a_page"
和 objRS("P_description")
code> 它返回值,但由于某种原因,使用下面的代码时我的页面将无法加载。
更新:接下来我关闭了错误恢复,我收到的错误是选择权限被拒绝。我如何使用下面的代码授予自己权限?
SQL = "select P_Name as P_Name, P_Description as P_Description from L_PagePermission inner join A_Permission on p_permissionID = pp_PermissionID inner join A_Page on P_PageID = PP_PageID where P_PageID = 84 order by p_Name"
Page_ID = 84
connectionstring = obj_ADO.getconnectionstring
Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
objCon.Open connectionstring
SQL = "select P_Name as P_Name, P_Description as P_Description from L_PagePermission inner join A_Permission on p_permissionID = pp_PermissionID inner join A_Page on P_PageID = PP_PageID where P_PageID = 84 order by p_Name"
objRS.open SQL, objCon
objRS.MoveFirst
while not objRS.EOF
response.Write objRS("P_Name")
objRS.MoveNext
wend
objRS.close
objCon.close
I'm trying to return values of a specific column using the below sql string, If I change it out to sql = "select * from a_page"
and objRS("P_description")
it returns the values but for some reason my page will not load when using the below code.
UPDATE: I turned off on error resume next and the error I'm receiving is select permission denied. How would I give myself permissions with the code below?
SQL = "select P_Name as P_Name, P_Description as P_Description from L_PagePermission inner join A_Permission on p_permissionID = pp_PermissionID inner join A_Page on P_PageID = PP_PageID where P_PageID = 84 order by p_Name"
Page_ID = 84
connectionstring = obj_ADO.getconnectionstring
Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
objCon.Open connectionstring
SQL = "select P_Name as P_Name, P_Description as P_Description from L_PagePermission inner join A_Permission on p_permissionID = pp_PermissionID inner join A_Page on P_PageID = PP_PageID where P_PageID = 84 order by p_Name"
objRS.open SQL, objCon
objRS.MoveFirst
while not objRS.EOF
response.Write objRS("P_Name")
objRS.MoveNext
wend
objRS.close
objCon.close
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到的错误加上您提到的有效代码意味着一件事:在
L_PagePermission
表或A_Permission
(或两者)上,在连接字符串中传递的用户没有 Read权限。要解决此问题,您必须在连接字符串中传递“更强”的用户,或者通过 SQL Management Studio 之类的工具向用户授予对这些表的读取权限。
顺便说一句,由于明显的安全原因,您不能通过代码“授予自己权限” - 权限的存在是为了防止代码首先执行某些操作。
The error you get plus the code you mentioned that is working means one thing: on either
L_PagePermission
table orA_Permission
(or both) the user passed in the connection string has no Read permissions.To solve this, you have to either pass "stronger" user in the connection string, or grant Read permissions to the user over those tables via something like SQL Management Studio.
By the way, you can't "grant yourself permissions" through code due to obvious security reasons - permissions exist to prevent code from doing certain things in the first place.