Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

WebSecurity InitializeDatabaseConnection Method

WebSecurity - InitializeDatabaseConnection()


WebSecurity Object WebSecurity object


define

InitializeDatabaseConnection() The method initializes the WebSecurity database.

The method initializes by connecting to the database containing user and membership information WebSecurity system.


C# and VB syntax

WebSecurity.InitializeDatabaseConnection(

connectionString, userTableName, userIdColumn, userNameColumn, autoCreateTables

)


Parameters

Parameters Type Description
connectionString String

Your WebSecurity database name

userTableName String The database containing user profile information table
userIdColumn String The database column containing the user ID (primary key) column
userNameColumn String The database column containing the username column
autoCreateTables Boolean true Indicates whether the user profile and membership tables must be created if they do not exist; otherwise false。

Return Value

none.


Notes

If SQL Server Compact is used,connectionString should be the name of the WebSecurity database (without the .sdf file extension). Otherwise it should be the name of the connection string in the web configuration (web.config file).

Note Even if autoCreateTables forces the database table to be created automatically, the precondition is that Database itself must already exist.

Errors and exceptions

In the following cases,InitializeDatabaseConnection() The method throws an InvalidOperationException:


Technical data

Name Value
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll

WebSecurity Object WebSecurity object