对象“地址"、数据库“CNET_85731"、架构“dbo"的 SELECT 权限被拒绝 [英] The SELECT permission was denied on the object 'Address', database 'CNET_85731', schema 'dbo'

查看:34
本文介绍了对象“地址"、数据库“CNET_85731"、架构“dbo"的 SELECT 权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去 7 个月我一直在使用 Visual Studio 2008 和 SQL Server 2008 开发 C# ASP.NET.

I have been working away for the last 7 months on a C# ASP.NET using Visual Studio 2008 and SQL Server 2008.

今天,我正在运行之前运行的应用程序的一部分,但出现以下错误:

Today, I was running part of my application which was previously running and I got the following error:

对象地址"、数据库CNET_85731"、架构dbo"的 SELECT 权限被拒绝.

The SELECT permission was denied on the object 'Address', database 'CNET_85731', schema 'dbo'.

我浏览了我的代码,发现此错误是由以下用户控件引起的:

I walked through my code and discovered that this error was being caused in the following User Control:

protected void sdsAddressesList_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
    if (e.AffectedRows == 0)
    {
        ddlAddresses.Items.Insert((0), new ListItem("No Billing Addresses", "0"));
    }
}

SQLDataSource 定义如下:

the SQLDataSource is defined as follows:

<asp:SqlDataSource ID="sdsAddressesList" runat="server" OnSelecting="sdsAddressesList_Selecting" OnSelected="sdsAddressesList_Selected"
    SelectCommand="SELECT [AddressId], [ZipPostalCode], ZipPostalCode + '&nbsp;--&nbsp;' + Address1 AS CombinedAddress FROM [Address] WHERE ([CustomerID] = @CustomerID AND [IsBillingAddress] = @IsBillingAddress) ORDER BY [ZipPostalCode]"
    ConnectionString="<%$ ConnectionStrings:eCoSysConnection %>">
    <SelectParameters>
        <asp:Parameter Name="CustomerID" Type="Int32" />
        <asp:Parameter Name="IsBillingAddress" Type="Boolean" />
    </SelectParameters>
</asp:SqlDataSource>

基本上,控件的作用是从 [Address] 表中检索登录用户的地址列表,然后填充下拉列表 ddlAddresses.

Basically, what the control does is retrieve a list of addresses for the logged on user from the [Address] table and then populate the drop down list ddlAddresses.

地址表与数据库中的其余表具有相同的权限.我有大约 60 个表和大约 200 个存储过程,它们都在愉快地执行 SELECT 等操作.没问题.除了这一个问题.这到底是怎么回事?我没有对数据库或表权限进行任何更改.

The Address table has all the same permissions as the rest of the tables in the database. I have around 60 tables and approximately 200 stored procedures all merrily working away doing SELECTs, etc. No problem. Except for this one issue. What on earth is going on? I haven't made any changes to the database or table permissions.

谁能帮帮我.

问候

沃尔特

推荐答案

如问题所述,对象‘地址’、数据库‘CNET_85731’、架构‘dbo’的 SELECT 权限被拒绝".

As problem states, "The SELECT permission was denied on the object 'Address', database 'CNET_85731', schema 'dbo' ".

我想知道你可以很简单地解决这个问题:

I wonder you can quite simply solve this way:

  • 打开 SQL Server 管理工作室
  • 导航到数据库CNET_85731">>安全>>用户
  • 右键单击您在代码中使用的那个
  • 最后,只需在数据库角色成员资格"部分中选择db_datareader".

现在,我希望你不要再出现这个错误.

Now, I hope you should not get this error again.

这篇关于对象“地址"、数据库“CNET_85731"、架构“dbo"的 SELECT 权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆