WebSecurity - InitializeDatabaseConnection()
WebSecurity Object
Definition
InitializeDatabaseConnection()The method initializes the WebSecurity database.
This method initializes by connecting to a database that contains user and membership information.WebSecuritysystem.
C# and VB Syntax
WebSecurity.InitializeDatabaseConnection(connectionString, userTableName,
userIdColumn, userNameColumn, autoCreateTables)
Parameters
| Parameters | Type | Description |
|---|---|---|
| connectionString | String |
YourWebSecurityThe name of the database |
| userTableName | String | The database that contains user profile informationTable |
| userIdColumn | String | The database that contains the user ID (primary key)Column |
| userNameColumn | String | The database that contains the usernameColumn |
| autoCreateTables | Boolean | trueIndicates that the tables must be created if the user profile and membership tables do not exist; otherwise it isfalse。 |
Return Value
None.
Remarks
If you are using SQL Server Compact,connectionStringIt should be the name of the WebSecurity database (without the .sdf file extension). Otherwise, it should be the name of a connection string in the Web configuration (web.config file).
![]() |
Even ifautoCreateTableswill force the databaseTableto be automatically created, but only ifthe databaseitself must already exist. |
|---|
Errors and Exceptions
In the following cases,InitializeDatabaseConnection()the method throws anInvalidOperationException:
- SimpleMembershipnot initialized (or disabled in the website configuration)
Technical Data
| Name | Value |
|---|---|
| Namespace | WebMatrix.WebData |
| Assembly | WebMatrix.WebData.dll |
WebSecurity Object Other Extensions
