在用VS2008開發網站時,調試代碼時(選擇了附加到進程的方法進行調試),在執行一個SQL查詢時報以下錯誤: “/VM”應用程式中的伺服器錯誤。 拒絕了對對象 'sp_sdidebug'(資料庫 'master',所有者 'dbo')的 EXECUTE 許可權。
說明: 執行當前 Web 請求期間,出現未處理的異常。請檢查堆疊追蹤資訊,以瞭解有關該錯誤以及代碼中導致錯誤的出處的詳細資料。
異常詳細資料: System.Data.SqlClient.SqlException: 拒絕了對對象 'sp_sdidebug'(資料庫 'master',所有者 'dbo')的 EXECUTE 許可權。
源錯誤:
行 116:dsCommand.SelectCommand.CommandText=sql;行 117:dsCommand.SelectCommand.CommandType=CommandType.Text;行 118:dsCommand.SelectCommand.Connection.Open();行 119:try行 120:{ |
源檔案: D:/Work/VM/SqlServerDAL/SqlLink.cs
行: 118
堆疊追蹤:
[SqlException (0x80131904): 拒絕了對對象 'sp_sdidebug'(資料庫 'master',所有者 'dbo')的 EXECUTE 許可權。] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1948826 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4844747 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +204 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137 System.Data.SqlClient.SqlConnection.IssueSQLDebug(UInt32 option, String machineName, UInt32 pid, UInt32 id, String sdiDllName, Byte[] data) +561 System.Data.SqlClient.SqlConnection.CheckSQLDebug(SqlDebugContext sdc) +129 System.Data.SqlClient.SqlConnection.CheckSQLDebugOnConnect() +349 System.Data.SqlClient.SqlConnection.CompleteOpen() +4874985 System.Data.SqlClient.SqlConnection.Open() +185 Vm.SqlServerDAL.SqlLink.SelectSqlSet(String sql) in D:/Work/VM/SqlServerDAL/SqlLink.cs:118 Vm.SqlServerDAL.BaseEntity.clsCity.Load_HomeOftenCity() in D:/Work/VM/SqlServerDAL/BaseEntity/clsCity.cs:452 Vm.Vm.business.Hotel.HotelSearchGuoNei.bindChangQuCity() in D:/Work/VM/Web/business/hotel/HotelSearchGuoNei.aspx.cs:39 Vm.Vm.business.Hotel.HotelSearchGuoNei.Page_Load(Object sender, EventArgs e) in D:/Work/VM/Web/business/hotel/HotelSearchGuoNei.aspx.cs:30 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627 |
版本資訊: Microsoft .NET Framework 版本:2.0.50727.3053; ASP.NET 版本:2.0.50727.3053
百度了一下,解決方案如下:
在.net中調用時出現“拒絕了對對象 'sp_sdidebug'(資料庫 'master',所有者 'dbo')的 EXECUTE 許可權”的錯誤的解決辦法。
該問題是我在用指定的URL啟動項目後,再“附加進程”後運行程式時出現的。該問題主要是.net2005的調試機制引起的,當已啟動程式,再附加進程後,他預設是要對SQL Server 也要進行調試的,可這需要裝補丁才能支援。所以就出現了“拒絕了對對象 'sp_sdidebug'(資料庫 'master',所有者 'dbo')的 EXECUTE 許可權”的錯誤。這時我們可以通過更改它的偵錯類型來處理該問題,並使調試正常進行。
在“附加到進程”對話方塊中點擊“附加到:”後的“選擇”按鈕,可以看到它預設的選項是“自動確定要調試的代碼類型”。完後選中“調試以下代碼”,並只選擇“託管”。這樣就可以正常進行了。
另外,若項目整體無法啟動調試,也可以先在項目屬中指定從某一URL進行調試,完後在啟動之後通過上面的方法將該進程附加到調試器中也可以實現對項目的調試。