Share via


WebSecurity.InitializeDatabaseConnection Method (String, String, String, String, Boolean)

Initializes the membership system by connecting to a database that contains user information and optionally creates membership tables if they do not already exist.

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

Syntax

'Declaration
Public Shared Sub InitializeDatabaseConnection ( _
    connectionStringName As String, _
    userTableName As String, _
    userIdColumn As String, _
    userNameColumn As String, _
    autoCreateTables As Boolean _
)
'Usage
Dim connectionStringName As String 
Dim userTableName As String 
Dim userIdColumn As String 
Dim userNameColumn As String 
Dim autoCreateTables As Boolean 

WebSecurity.InitializeDatabaseConnection(connectionStringName, _
    userTableName, userIdColumn, userNameColumn, _
    autoCreateTables)
public static void InitializeDatabaseConnection(
    string connectionStringName,
    string userTableName,
    string userIdColumn,
    string userNameColumn,
    bool autoCreateTables
)
public:
static void InitializeDatabaseConnection(
    String^ connectionStringName, 
    String^ userTableName, 
    String^ userIdColumn, 
    String^ userNameColumn, 
    bool autoCreateTables
)
static member InitializeDatabaseConnection : 
        connectionStringName:string * 
        userTableName:string * 
        userIdColumn:string * 
        userNameColumn:string * 
        autoCreateTables:bool -> unit
public static function InitializeDatabaseConnection(
    connectionStringName : String, 
    userTableName : String, 
    userIdColumn : String, 
    userNameColumn : String, 
    autoCreateTables : boolean
)

Parameters

  • connectionStringName
    Type: System.String
    The name of the connection string for the database that contains user information. If you are using SQL Server Compact, this can be the name of the database file (.sdf file) without the .sdf file name extension.
  • userTableName
    Type: System.String
    The name of the database table that contains the user profile information.
  • userIdColumn
    Type: System.String
    The name of the database column that contains user IDs. This column must be typed as an integer (int).
  • userNameColumn
    Type: System.String
    The name of the database column that contains user names. This column is used to match user profile data to membership account data.
  • autoCreateTables
    Type: System.Boolean
    true to indicate that user profile and membership tables should be created if they do not exist; false to indicate that tables should not be created automatically. Although the membership tables can be created automatically, the database itself must already exist.

Remarks

For more information, see InitializeDatabaseConnection().

See Also

Reference

WebSecurity Class

InitializeDatabaseConnection Overload

WebMatrix.WebData Namespace