问题:
===================================
无法作为数据库主体执行,因为主体 “dbo” 不存在、无法模拟这种类型的主体,或您没有所需的权限。 (.Net SqlClient Data Provider)
——————————
有关帮助信息,请单击: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=13.00.4206&EvtSrc=MSSQLServer&EvtID=15517&LinkId=20476
——————————
服务器名称: .
错误号: 15517
严重性: 16
状态: 1
行号: 1
——————————
程序位置:
在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
在 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
在 System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
在 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
在 System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
在 Microsoft.SqlServer.Management.UI.VSIntegration.Editors.DatabaseDiagramSupport.InstallSupportObjects(SqlConnectionInfoWithConnection connectionInfo, Urn databaseUrn)
解决办法:
1 2 | USE 出问题的库名; EXEC sp_changedbowner '数据库系统管理员' ; |
查看数据库的所有者:
1 2 3 | select owner_sid ,lo.sid, lo. name , lo.loginname ,db_name(database_id) from master.sys.databases da inner join sys.syslogins lo on da.owner_sid = lo.sid |