该SELECT权限被拒绝的对象,“地址”,数据库'CNET_85731“,架构”DBO“
我有一个C#ASP.NET过去7内通过Visual Studio 2008和SQL Server 2008中已经工作了。
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:
SELECT权限被拒绝的对象,地址,数据库'CNET_85731,架构DBO。
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 + ' -- ' + 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>
基本上,控制的作用是获取地址的列表为登录用户从[地址]表,然后填充下拉列表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.
谁能帮我请。
问候
沃尔特
作为问题国家的SELECT权限。被拒绝的对象,地址,数据库'CNET_85731'模式'DBO'。
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 Management Studio中
- 导航到数据库CNET_85731'>>安防产品>>用户
- 右键点击其中一个你正在使用你的代码
- 最后,只需选择的db_datareader 里面的数据库角色成员一节。
- Open SQL Server Management studio
- Navigate to the database 'CNET_85731' >> Security >> Users
- Right click on the one which you are using in your code
- And finally, just select 'db_datareader' inside "Database Role membership" section.
现在,我希望你不要再出现此错误。
Now, I hope you should not get this error again.