2016-11-22 102 views
0

我用數據庫做了一個Web應用程序,在sql server express中 我打開服務器並在visual studio中建了表(我找不到另一種方式) 當我去Data Base網站(在線)是說我沒有權限, 有誰知道我如何通過Visual Studio添加權限?sql server express權限

錯誤:

Server Error in '/' Application.

The SELECT permission was denied on the object 'UsersTable', database 'master', schema 'dbo'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: The SELECT permission was denied on the object 'UsersTable', database 'master', schema 'dbo'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): The SELECT permission was denied on the object 'UsersTable', database 'master', schema 'dbo'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction) +3279580
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +791
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4927
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +92
System.Data.SqlClient.SqlDataReader.get_MetaData() +102
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +552
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +3114
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource
1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +554
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +98
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +307
System.Data.SqlClient.SqlCommand.ExecuteReader() +132
KIP_FP.KIPDB.chackUser(String userN) in C:\Users\Administrator\Documents\KIP-FP\KIP-FP\KIPDB.cs:31
KIP_FP.KIPBL.chackUser(String userN) in C:\Users\Administrator\Documents\KIP-FP\KIP-FP\KIPBL.cs:37
KIP_FP.loginUserPage.Button1_Click(Object sender, EventArgs e) in C:\Users\Administrator\Documents\KIP-FP\KIP-FP\Login.aspx.cs:34
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11750641
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +150 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6016

+0

您是否創建了一個新的數據庫,或者只創建了Master數據庫中的表? –

+1

不相關,但您可能想嘗試使用SQL Management Studio,而不是通過Visual Studio進行。 –

回答

0

你有權作出選擇的UsersTable表,但你的web應用程序的應用程序池沒有它,因爲它是在不具有權限的其他用戶帳戶下運行。 要添加您必須運行這樣的權限:

USE master; 
GRANT SELECT ON OBJECT::dbo.UsersTable TO PoolUser; 
GO 

但首先你應該找出哪些用戶在App。池。

+0

我怎麼知道在哪裏找出App上的哪個用戶。池? –

+0

我認爲你的網絡服務器是IIS,所以這個MS文章應該有所幫助: https://www.iis.net/learn/manage/configuring-security/application-pool-identities 你需要找出你的池的身份。 –