WebSecurity – InitializeDatabaseConnection()
❮ WebSecurity
Definice
Metoda InitializeDatabaseConnection() inicializuje databázi WebSecurity.
Metoda inicializuje systém WebSecurity připojením k databázi, která obsahuje informace o uživatelích a členství.
Syntaxe C# a VB
WebSecurity.InitializeDatabaseConnection(connectionString, userTableName,
userIdColumn, userNameColumn, autoCreateTables)
Parametry
Parameter | Type | Description |
---|---|---|
connectionString | String |
The name of your WebSecurity database (se remarks) |
userTableName | String | The database table that contains the user profile information |
userIdColumn | String | The database column that contains the user IDs (primary keys) |
userNameColumn | String | The database column that contains the user names |
autoCreateTables | Boolean | true indicates that user profile and membership tables should be created if they do not exist, otherwise false |
Návratová hodnota
Žádný.
Poznámky
Pokud používáte SQL Server Compact, connectionString by měl být název databáze WebSecurity (bez přípony názvu souboru .sdf). Jinak by to měl být název připojovacího řetězce ve webové konfiguraci (soubor web.config).
I když autoCreateTables může vynutit automatické vytvoření databázových tabulek , samotná databáze musí vždy existovat.
Chyby a výjimky
Metoda InitializeDatabaseConnection() vyvolá výjimku InvalidOperationException , pokud:
- SimpleMembership není inicializováno (nebo zakázáno v konfiguraci webu)
❮ WebSecurity