Table of Contents

Class ConnectionStringBuilder

Namespace
Tripous.Data
Assembly
Tripous.Data.dll

Provides helper methods and strongly typed accessors for manipulating database connection strings.

public class ConnectionStringBuilder : DbConnectionStringBuilder, IDictionary, ICollection, IEnumerable, ICustomTypeDescriptor
Inheritance
ConnectionStringBuilder
Implements
Inherited Members
Extension Methods

Constructors

ConnectionStringBuilder()

Initializes a new instance.

public ConnectionStringBuilder()

ConnectionStringBuilder(bool)

Initializes a new instance using the specified ODBC parsing rules.

public ConnectionStringBuilder(bool UseOdbcRules)

Parameters

UseOdbcRules bool

ConnectionStringBuilder(bool, string)

Initializes a new instance using the specified ODBC parsing rules and connection string.

public ConnectionStringBuilder(bool UseOdbcRules, string ConnectionString)

Parameters

UseOdbcRules bool
ConnectionString string

ConnectionStringBuilder(string)

Initializes a new instance using the specified connection string.

public ConnectionStringBuilder(string ConnectionString)

Parameters

ConnectionString string

Fields

AliasKey

The connection string key used to store an alias.

public const string AliasKey = "Alias"

Field Value

string

Properties

Alias

Gets or sets the connection alias.

public string Alias { get; set; }

Property Value

string

Database

Gets the database name or database file path, depending on the provider.

public string Database { get; }

Property Value

string

ExtendedProperties

Gets or sets the OLE DB extended properties value.

public string ExtendedProperties { get; set; }

Property Value

string

this[string]

Gets or sets a value associated with the specified key. Returns an empty string when the key does not exist.

public override object this[string Key] { get; set; }

Parameters

Key string

Property Value

object

OleDbProvider

Gets or sets the OLE DB provider name.

public string OleDbProvider { get; set; }

Property Value

string

Password

Gets the password from the connection string.

public string Password { get; }

Property Value

string

Server

Gets the database server name or address.

public string Server { get; }

Property Value

string

User

Gets the user name from the connection string. Supports common key variations such as User, UserId, User ID and UID.

public string User { get; }

Property Value

string

Methods

CreateConnectionStringBuilder(string)

Creates a new connection string builder initialized from the specified connection string. If no alias is present, the current alias is copied to the new builder.

public virtual ConnectionStringBuilder CreateConnectionStringBuilder(string ConnectionString)

Parameters

ConnectionString string

Returns

ConnectionStringBuilder

ExtractAlias(string, ref string, ref string)

Extracts the alias and the remaining connection string.

public static void ExtractAlias(string Input, ref string Alias, ref string ConnectionString)

Parameters

Input string
Alias string
ConnectionString string

FromDataTable(DataTable)

Loads connection string entries from a data table.

public void FromDataTable(DataTable Table)

Parameters

Table DataTable

GetAlias(string)

Returns the alias stored in a connection string.

public static string GetAlias(string ConnectionString)

Parameters

ConnectionString string

Returns

string

GetFirst(string[])

Returns the first non-empty value found among the specified keys.

public string GetFirst(string[] Keys)

Parameters

Keys string[]

Returns

string

NormalizeConnectionString(string)

Removes the alias entry and expands any path placeholders.

public static string NormalizeConnectionString(string ConnectionString)

Parameters

ConnectionString string

Returns

string

RemoveAliasEntry(string)

Removes the alias entry from a connection string.

public static string RemoveAliasEntry(string ConnectionString)

Parameters

ConnectionString string

Returns

string

RemoveKeys(string[])

Removes all specified keys from the connection string.

public void RemoveKeys(string[] Keys)

Parameters

Keys string[]

ReplacePathPlaceholders(string)

Replaces all supported path placeholders with physical paths.

public static string ReplacePathPlaceholders(string ConnectionString)

Parameters

ConnectionString string

Returns

string

SetConnectionString(string)

Sets the connection string.

public void SetConnectionString(string ConnectionString)

Parameters

ConnectionString string

ToDataTable()

Converts the connection string entries to a new data table.

public DataTable ToDataTable()

Returns

DataTable

ToDataTable(DataTable)

Populates the specified data table with the connection string entries.

public void ToDataTable(DataTable Table)

Parameters

Table DataTable

TryGetValue(string, out string)

Tries to retrieve a value associated with the specified key.

public bool TryGetValue(string Key, out string Value)

Parameters

Key string
Value string

Returns

bool