Gravatar for

Question by ppande, Jan 29, 2015 1:19 AM

LinqPad queries returning SQL Exceptions

I installed LinqPad and was running a default query which returned a SQL exception. Sitecore site runs fine. There is no SQL exception there. Here's the query:

var index = ContentSearchManager.GetIndex("Coveo_web_index");
using (var context = index.CreateSearchContext())
    .Where(item => item.Name == "Home")
      .Where(item => item.Language == "en")
        .Select(item => new {Name = item.Name, Id = item.ItemId.ToString()})

Here's the error:

Exception: System.Web.HttpException
Message: Unable to connect to SQL Server database.
Source: System.Web
   at System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trusted, String connectionString)
   at System.Web.Management.SqlServices.SetupApplicationServices(String server, String user, String password, Boolean trusted, String connectionString, String database, String dbFileName, SqlFeatures features, Boolean install)
   at System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString)
   at System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString)
   at System.Web.DataAccess.SqlConnectionHelper.EnsureDBFile(String connectionString)
   at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)
   at System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate)
   at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat)
   at System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password)
   at Sitecore.Security.Authentication.AuthenticationHelper.ValidateUser(String userName, String password)
   at Sitecore.Security.Authentication.MembershipAuthenticationProvider.Login(String userName, String password, Boolean persistent)
   at Sitecore.Security.Authentication.AuthenticationManager.Login(String userName, String password)
   at Coveo.Framework.Utils.AuthenticationManagerWrapper.Login(String p_Username, String p_Password)
   at Coveo.Framework.Configuration.CoveoIndexConfiguration.Validate()
   at Coveo.SearchProvider.ProviderIndexBase.Initialize(IIndexDocumentPropertyMapper`1 p_DocumentTypeMapper)
1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Jan 29, 2015 8:58 AM

The error is thrown when Coveo for Sitecore validates its configuration while initializing.

Is your Sitecore administrator username is "admin" and its password is "b". If that's not the case, you need to set them in the Coveo for Sitecore configuration.

See step #16 of the installation procedure: Or check the procedure to set your administrator credentials:

The error may be caused by another configuration problem. Try to run the Coveo for Sitecore Diagnostic Page to check if everything is green and running correctly.

Gravatar for

Comment by ppande, Jan 29, 2015 11:43 AM

Diagnostic Page is all green. And I have the default credentials locally "admin" "b". Is there some other setting that might be causing this?

Gravatar for

Comment by Jean-François L'Heureux, Jan 29, 2015 1:48 PM

Unfortunately, I don't think it would work right now. Coveo for Sitecore is validating the configured SitecoreUsername and SitecorePassword against the web app authentication manager (in your case an SqlMembershipProvider, in my case a FormsAuthenticationProvider). This doesn't work very well when this code is executed outside of an HTTP request to a Sitecore page.

We'll try to improve this in a future release.

Gravatar for

Comment by ppande, Jan 29, 2015 4:20 PM

Do you have any recommendations on how I can test my coveo queries in LINQ?

Gravatar for

Comment by Simon, Dec 5, 2015 12:09 PM

Using the CES Console, you can see the generated query once it is launched

Ask a question