Database.OpenConnectionString Method (String)

Opens a connection to a database using the specified connection string.

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

public static Database OpenConnectionString(
	string connectionString
)

Parameters

connectionString
Type: System.String
The connection string that contains information that is used to connect to a database.

Return Value

Type: WebMatrix.Data.Database
The database instance.

ExceptionCondition
ArgumentException

connectionString is null or empty.

The OpenConnectionString method differs from the Open method, which uses the name of a connection string that is stored in the Web.config file.

You might use the OpenConnectionString method when a connection string is programmatically generated or is provided by the user.

  • Medium trust for the immediate caller. This member can be used by partially trusted code.
Show: