AdvantageCMS.Core.Common.BaseClasses Namespace
Build With Advantage

SQL..::..GetConnectionString Method

Gets the connection string from the config file.
Resolves the connection string for this SQL instance, using this lookup order:
  1. The explicit value previously set via SetConnectionString(String).
  2. The per-thread ambient pushed via Scope(String), if any.
  3. ConfigurationManager.ConnectionStrings[_ConnectionID] if a ConnectionID was supplied to the constructor.
  4. ConfigurationManager.AppSettings["DefaultConnection"] resolved against ConnectionStrings.
  5. The first entry in ConfigurationManager.ConnectionStrings as a last-resort fallback.
The ambient (step 2) is checked BEFORE any ConfigurationManager lookup so callers running inside a Scope(String) bypass web.config entirely — used by the InitializeCSP wizard's Step 5 to build the first domain before web.config is written.

Namespace:  AdvantageCMS.Data
Assembly:  AdvantageCMS.Data (in AdvantageCMS.Data.dll)

Syntax


public string GetConnectionString()

Return Value

The connection string.

Return Value

The resolved connection string, or String if no source produced one.

Exceptions


ExceptionCondition
InvalidOperationException