Tags: Moduler Optimizely/Episerver SQL

Increase timeout for long running SQL queries using SQL addon

I recently got a question about the possibility of increasing SQL timeout when using the addon for Optimizely CMS, Gulla.Episerver.SqlStudio.

This addon will let you query the database directly from the Optimizely/Episerver user interface. The result set can be exported to Excel, CSV, or PDF. There is, of course, some AI features as well!

The addon has no explicit option for configuring the timeout, but there is a way! You can add an extra connection string like this, with the desired timeout at the end of the connection string, using an initialization module.

[InitializableModule]
public class ContentTypeInitialization : IInitializableModule
{
    public void Initialize(InitializationEngine context)
    {
        var dao = ServiceLocator.Current.GetInstance<DataAccessOptions>();
        dao.ConnectionStrings.Add(new ConnectionStringOptions() { Name = "SQL Addon", ConnectionString = "Data Source=db.net;Database=mydb;User Id=uid;Password=pwd;Connection Timeout=30" });
    }
    public void Uninitialize(InitializationEngine context)
    {
    }
}

Then you will get a dropdown list in the plugin UI where you can select between the two available connection strings.

Dropdown list for selecting connection string: EpiServerDB or SQL Addon.

When you need to execute those long running queries, use the connection string with extended timeout!

That's all!

Found this post helpful? Help keep this blog ad-free by buying me a coffee! ☕