2016-04-05 22 views
0

ASP.NETアプリケーションをIISにデプロイしました。最初はうまくいった。しかし、突然それはエラーを与えます。私は何も変えていない。しかし、ビジュアルスタジオの内蔵サーバーを使ってそのアプリケーションをデプロイすると、正常に動作しました。エラーは、IISが自分のデータベースを見つけることができないと示しています。これはどうやって起こりましたか? これは、エラーメッセージとスタックトレースIISサーバーを使用してASP.NETアプリケーションをデプロイできない

Cannot open database "VistasDb" requested by the login. The login failed. 
Login failed for user 'IIS APPPOOL\DefaultAppPool'. 

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: Cannot open database "VistasDb" requested by the login. The login failed. 
Login failed for user 'IIS APPPOOL\DefaultAppPool'. 


[SqlException (0x80131904): Cannot open database "VistasDb" requested by the login. The login failed. 
Login failed for user 'IIS APPPOOL\DefaultAppPool'.] 
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6564850 
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +815 
    System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4515 
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +84 
    System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53 
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +368 
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +6592502 
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +6592983 
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +878 
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1162 
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +72 
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +6596173 
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +103 
    System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +2102 
    System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116 
    System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1079 
    System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6600667 
    System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +233 
    System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +278 
    System.Data.SqlClient.SqlConnection.Open() +239 
    System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +292 
    System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +420 
    System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +277 
    System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +3318587 
    System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +176 
    System.Web.UI.WebControls.ListControl.PerformSelect() +51 
    System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +146 
    System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +36 
    System.Web.UI.Control.PreRenderRecursiveInternal() +113 
    System.Web.UI.Control.PreRenderRecursiveInternal() +222 
    System.Web.UI.Control.PreRenderRecursiveInternal() +222 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4297 
+1

エラーメッセージはきわめて明確です:ログインで要求することはできません 'オープンデータベース「VistasDb」。ログインに失敗しました。ユーザー 'IIS APPPOOL \ DefaultAppPool'のログインに失敗しました。 - 上記ユーザーがデータベースに接続できません。 –

+0

しかし、最初はうまくいきました。私はこのことがどうやって起こりうるのか、この問題をどう解決するのかを知りたがっていました。 – progmo

答えて

1

のSQL Serverにログインするために使用Windows Authenticationです。 その後:

Security - >Logins - >(右クリック)create a new login name

選択SQL Server Authenticationlogin namepasswordを書きます。

は、このようなあなたのweb.configファイルを変更します。

<appSettings> 
    <add key="dbconnectstring" value="server=your db server address;database=dbname;uid=login name;pwd=password;"/> 
</appSettings> 
+0

動作しません。なぜこれが起こっているのか、これを解決する方法を教えてください。 – progmo

+0

"データベースを開くことができません" VistasDb ""つまり、データベースとの接続が正しくないことを意味するため、接続を最初にテストする必要があります。 – gdreamlend

関連する問題