经典的asp记录集权限问题

发布于 2024-11-16 17:17:41 字数 1030 浏览 3 评论 0原文

我正在尝试使用下面的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-11-23 17:17:41

您收到的错误加上您提到的有效代码意味着一件事:在 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 or A_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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文