WebConfig..::..GetConnectionString Method

Gets a connection string from the connectionStrings node in config. Note that this method reads from the configuration section, not the appSettings one.

Namespace:  Core
Assembly:  Core (in Core.dll)

Syntax


public static string GetConnectionString(
	string keyName
)

Parameters

keyName
Type: String
The name of the key, as specified in application config.

Return Value

A connection string from the config file.

Exceptions


ExceptionCondition
ConfigurationErrorsExceptionNo connection string section was found or no entry present with specified key.

Remarks


Config sections for connection strings look like this:
C#
<configuration>
<connectionStrings>
<add name="NAV" connectionString="Data Source=SERVER;Initial Catalog=DATABASE;User ID=USER;Password=PASSWORD"/>
</connectionStrings>
</configuration>