Creating new connection string in Sitecore throws exception

Reading Time: 2 minutes

I was trying to add new publishing target into my Sitecore 9 instance when I received this error message while logging into Sitecore or doing basically anything with Sitecore:

connectionstringerror.PNG

Textual representation of exception:

Server Error in ‘/’ Application.


One or more exceptions occurred while processing the subscribers to the ‘property:changed’ event.

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.AggregateException: One or more exceptions occurred while processing the subscribers to the ‘property:changed’ event.

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:

[AggregateException: One or more exceptions occurred while processing the subscribers to the 'property:changed' event.]
   Sitecore.Events.EventSubscribers.RaiseEvent(String eventName, Object[] parameters, EventResult result) +1849
   Sitecore.Events.Event.RaiseEvent(String eventName, Object[] parameters) +422
   Sitecore.Data.Properties.PropertyStore.RaiseEvent(String name, Object[] parameters) +85
   Sitecore.Web.Authentication.DefaultTicketManager.IsTicketExpired(Ticket ticket, Boolean useProlongation) +357
   Sitecore.Web.Authentication.DefaultTicketManager.GetTicket(String ticketId, Boolean returnExpired) +118
   Sitecore.Web.Authentication.DefaultTicketManager.IsTicketValid(String ticketId) +49
   Sitecore.Shell.Web.ShellPage.IsLoggedIn(Boolean returnAfterLogin) +314
   Sitecore.Shell.Web.UI.SecurePage.OnLoad(EventArgs e) +22
   System.Web.UI.Control.LoadRecursive() +154
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4088

 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2623.0

 

This exception arose when I added new connection string into ConnectionStrings.config file:

<add name="web_secondary" connectionString="Data Source=.\;Initial Catalog=webdbname;User ID=user ID;Password=Password" />

Exception as you can see above is not so informative therefore I couldn’t figure out instantly what is the root cause.

I dig deeper into Sitecore logs and puff I have found these entries:

ManagedPoolThread #2 12:56:18 ERROR Exception processing remote events from database: webdbname
Exception: System.Data.SqlClient.SqlException
Message: Login failed for user ‘webuser’.
Source: .Net SqlClient Data Provider
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Sitecore.Data.DataProviders.Sql.DataProviderCommand..ctor(IDbCommand command, DataProviderTransaction transaction, Boolean openConnection)
at Sitecore.Data.DataProviders.Sql.SqlDataApi.<>c__DisplayClass26_0.<CreateCommand>b__0()
at Sitecore.Data.DataProviders.NullRetryer.Execute[T](Func`1 action, Action recover)
at Sitecore.Data.DataProviders.Sql.SqlDataApi.<>c__DisplayClass29_0.<CreateReader>b__0()
at Sitecore.Data.DataProviders.NullRetryer.Execute[T](Func`1 action, Action recover)
at Sitecore.Data.DataProviders.Sql.SqlDataApi.CreateReader(String sql, Object[] parameters)
at Sitecore.Data.DataProviders.Sql.SqlDataApi.<CreateObjectReader>d__27`1.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at Sitecore.Eventing.EventQueue.ProcessEvents(Action`2 handler)
at Sitecore.Eventing.EventProvider.RaiseQueuedEvents()

 

Login failed for user for my secondary web database??

“Strange” I thought and then I knew instantly what is problem…

connectionstringerror

I have forgotten to attach the database that I was referring to as my secondary web db to SQL Server.

After attaching is, everything started to work as expected.

Hopefully this post will help somebody in the future 🙂

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.