WebSecurity InitializeDatabaseConnection method
definition
InitializeDatabaseConnection () method initializes WebSecurity database.
The method by connecting to a database that contains information about users and members to initialize WebSecurity system.
C # and VB syntax
WebSecurity.InitializeDatabaseConnection( connectionString, userTableName,
userIdColumn, userNameColumn, autoCreateTables )
parameter
参数 | 类型 | 描述 |
---|---|---|
connectionString | String |
您的 WebSecurity 数据库的名称 |
userTableName | String | 包含用户资料信息的数据库 表 |
userIdColumn | String | 包含用户 ID(主键)的数据库 列 |
userNameColumn | String | 包含用户名的数据库 列 |
autoCreateTables | Boolean | true 指示如果用户资料和会员表不存在则必须创建表,否则为 false 。 |
return value
no.
Remark
If you are using SQL Server Compact, connectionString WebSecurity should be the name of the database (without .sdf file extension). Otherwise, it should be the name of the configuration (web.config file) connection string in the Web.
Even autoCreateTables forces the database tables are created automatically, but the premise is the database itself must already exist. |
Errors and exceptions
In the following cases, InitializeDatabaseConnection () method throws an InvalidOperationException:
- SimpleMembership not initialized (or disabled in the site configuration)
Technical data
名称 | 值 |
---|---|
Namespace | WebMatrix.WebData |
Assembly | WebMatrix.WebData.dll |
WebSecurity objects